1.0.1 • Published 4 years ago

@lchooks/use-fullscreen v1.0.1

Weekly downloads
2
License
MIT
Repository
github
Last release
4 years ago

@lchooks/use-fullscreen

React Hook to make any element go Fullscreen

노마드코더 수업을 들으면서 클론코딩했습니다. Thank you nomadcoders!! https://academy.nomadcoders.co/p/introduction-to-react-hooks

Installation

yarn

yarn add @lchooks/use-fullscreen

npm

npm i @lchooks/use-fullscreen

Usage

import React from "react";
import useFullscreen from "@lchooks/use-fullscreen";

function App() {
  const onChange = isFull =>
    console.log(isFull ? "Nomadcoders are in Fullscreen" : "Nomadcoders are not in Fullscreen");
  const { element, triggerFull, exitFull } = useFullscreen(onChange);
  return (
    <div ref={element}>
      <h1>Hello</h1>
      <button onClick={triggerFull}>Make this Fullscreen</button>
      <button onClick={exitFull}>Exit Fullscreen</button>
    </div>
  );
}

Arguments

ArgumentTypeDescriptionArgumentsRequired
onChangefunctionFunction to be called when the screen goes Fullscreen or exits isisFull : Booleanno

Return

useFullscreen returns an object containing the following:

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

4 years ago

1.0.0

4 years ago