Skip to content

albinekb/use-screenfull

Repository files navigation

use-screenfull

React hook for screenfull.js

NPM JavaScript Style Guide

Install

npm install --save use-screenfull

Usage

import * as React from 'react'

import { useScreenfull } from 'use-screenfull'

const Example = () => {
  const { isFullscreen, toggle, requestFullscreen } = useScreenfull()
  const scale = isFullscreen ? 1 : 0.1

  return (
    <div>
      {isFullscreen ? 'yes' : 'no'}{' '}
      <img
        onClick={requestFullscreen}
        src="https://placekitten.com/1920/1080"
        width={1920 * scale}
        height={1080 * scale}
      />
    </div>
  )
}

License

MIT © albinekb