1.0.1 • Published 3 years ago

@ib-hooks/use-full-screen v1.0.1

Weekly downloads
-
License
MIT
Repository
github
Last release
3 years ago

@ib-hooks/use-full-screen

React Hook to make any element go full screen.

Installation

yarn

yarn add @ib-hooks/use-full-screen

npm

npm i @ib-hooks/use-full-screen

Usage

import React from "react";
import useFullScreen from "@ib-hooks/use-full-screen";

function App() {
  const onChange = (isFull) =>
    console.log(isFull ? "Full Screen Mode" : "Exit Full Screen");

  const { element, triggerFull, exitFull } = useFullscreen(onChange);

  return (
    <div ref={element}>
      <h1>Hello</h1>
      <button onClick={triggerFull}>Full Screen Mode</button>
      <button onClick={exitFull}>Exit Full Screen</button>
    </div>
  );
}

Arguments

ArgumentTypeDescriptionArgumentsRequired
onChangefunctionFunction to be called when the screen goes full screen or exitsisFull : Booleanno

Return

useFullScreen returns an object containing the following:

Return valueTypeDescription
elementReact RefRef to add to the element that you want to make full screen
triggerFullFunctionFunction to make the element enter full screen
exitFullFunctionFunction to make the document exit full screen