Giter Site home page Giter Site logo

cloudever / react-use Goto Github PK

View Code? Open in Web Editor NEW

This project forked from streamich/react-use

1.0 1.0 0.0 753 KB

React Hooks โ€” future of React ๐Ÿ‘ react-use

Home Page: http://streamich.github.io/react-use

License: The Unlicense

JavaScript 1.19% TypeScript 98.81%

react-use's Introduction



๐Ÿ‘
react-use






Collection of essential React Hooks.
Port of libreact to React Hooks. See demos.




npm i react-use


Reference

  • Sensors
    • useBattery โ€” tracks device battery state.
    • useGeolocation โ€” tracks geo location state of user's device.
    • useHover โ€” tracks mouse hover state of some element.
    • useIdle โ€” tracks whether user is being inactive.
    • useLocation โ€” tracks page navigation bar location state.
    • useMedia โ€” tracks state of a CSS media query.
    • useMediaDevices โ€” tracks state of connected hardware devices.
    • useMotion โ€” tracks state of device's motion sensor.
    • useNetwork โ€” tracks state of user's internet connection.
    • useOrientation โ€” tracks state of device's screen orientation.
    • useSize โ€” tracks some HTML element's dimensions.
    • useWindowSize โ€” tracks Window dimensions.

  • UI
    • useAudio โ€” plays audio and exposes its controls.
    • useSpeech โ€” synthesizes speech from a text string.

  • Animations
    • useRaf โ€” re-renders component on each reaquestAnimationFrame.
    • useSpring โ€” interpolates number over time according to spring dynamics.
    • useTimeout โ€” returns true after a timeout.
    • useTween โ€” re-renders component, while tweening a number from 0 to 1.

  • Side-effects
    • useAsync โ€” resolves an async function.
    • useCss โ€” dynamically adjusts CSS.
    • useFavicon โ€” sets favicon of the page.
    • useTitle โ€” sets title of the page.

  • Lifecycles
    • useLifecycles โ€” calls mount and unmount callbacks.
    • useLogger โ€” logs in console as component goes though life-cycles.
    • useMount โ€” calls mount callbacks.
    • useUnmount โ€” calls unmount callbacks.

  • State
    • useSetState โ€” creates setState method which works like this.setState.
    • useToggle โ€” tracks state of a boolean.
    • useCounter โ€” tracks state of a number.
    • useList โ€” tracks state of an array.
    • useMap โ€” tracks state of an object.

Usage

  • You need to have React 16.7.0-alpha.0 or later installed to use Hooks API.
  • You can import each hook individually import useToggle from 'react-use/lib/useToggle'.

License

Unlicense โ€” public domain.

react-use's People

Contributors

streamich avatar

Stargazers

 avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.