React Hooks

The React snippet collection contains function components and reusable hooks for React 16.

  • Executes a callback immediately after a component is mounted.

  • Executes a callback immediately before a component is unmounted and destroyed.

  • usePrevious

    React, Hooks

    Stores the previous state or props.

  • useToggler

    React, Hooks

    Provides a boolean state variable that can be toggled between its two states.

  • useClickInside

    React, Hooks

    Handles the event of clicking inside the wrapped component.

  • useClickOutside

    React, Hooks

    Handles the event of clicking outside of the wrapped component.

  • useDebounce

    React, Hooks

    Debounces the given value.

  • useFetch

    React, Hooks

    Implements fetch in a declarative manner.

  • useInterval

    React, Hooks

    Implements setInterval in a declarative manner.

  • useMediaQuery

    React, Hooks

    Checks if the current environment matches a given media query and returns the appropriate value.

  • useNavigatorOnLine

    React, Hooks

    Checks if the client is online or offline.

  • useSSR

    React, Hooks

    Checks if the code is running on the browser or the server.

  • useTimeout

    React, Hooks

    Implements setTimeout in a declarative manner.

  • useUnload

    React, Hooks

    Handles the beforeunload window event.

  • useAsync

    React, Hooks

    Handles asynchronous calls.