React Hooks

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

  • useLocalStorage

    React, Hooks

    Creates a stateful value that is persisted to localStorage, and a function to update it.

  • useSessionStorage

    React, Hooks

    Creates a stateful value that is persisted to sessionStorage, and a function to update it.

  • useUnload

    React, Hooks

    Handles the beforeunload window event.

  • useDebounce

    React, Hooks

    Debounces the given value.

  • useMergeState

    React, Hooks

    Creates a stateful value, and a function to update it by merging the new state provided.

  • 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.

  • Executes a callback immediately after a component is updated.

  • useEventListener

    React, Hooks

    Adds an event listener for the specified event type on the given element.

  • useMap

    React, Hooks

    Creates a stateful Map object, and a set of functions to manipulate it.

  • useMediaQuery

    React, Hooks

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

  • When working with multiple useState hooks in React, things can get a bit complicated while debugging. Luckily, there's an easy way to label these values.

  • useCopyToClipboard

    React, Hooks

    Copies the given text to the clipboard.

  • useError

    React, Hooks

    Creates an error dispatcher.

  • useForm

    React, Hooks

    Creates a stateful value from the fields in a form.