1.0.3 • Published 2 years ago

@hazesoft/use-hook v1.0.3

Weekly downloads
-
License
ISC
Repository
-
Last release
2 years ago

@hazesoft/use-hook

Installation

npm install @hazesoft/use-hook

or

yarn add @hazesoft/use-hook

Usage

import React from 'react'
import {useToggle, useMediaQuery, useDetectDevice} from "@hazesoft/use-hook";

const Example = () ={
  const [isOn, setIsOn] = useToggle()
  let breakpoint = useMediaQuery(767); // change to any breakpoint value
  const currentDevice = useDetectDevice();
  
 return (
    <div className="App">
        {currentDevice.isMobile() && 'mobile'} //currentDevice contains isMobile, isDesktop, isAndroid, isIos, isSSR to detect device 
        <br/>
        {breakpoint ? 'is-mobile' : 'is-desktop'} // useMediaQuery can use to render layout according to responsive breakpoint
        <button onClick={() => setIsOn(isOn => !isOn)}>button click {`${isOn}`}</button>
    </div>
  );
}
1.0.3

2 years ago

1.0.2

2 years ago

1.0.0

2 years ago