React Snippets

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

  • useTimeout

    React, Hooks

    Implements setTimeout in a declarative manner.

  • PasswordRevealer

    React, Components

    Renders a password input field with a reveal button.

  • Executes a callback immediately after a component is mounted.

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

  • useDefault

    React, Hooks

    Creates a stateful value with a default fallback if it's null or undefined, and a function to update it.

  • Learn the differences between PropTypes.objectOf() and PropTypes.shape() and where to use each one with this quick guide.

  • useInterval

    React, Hooks

    Implements setInterval in a declarative manner.

  • TextArea

    React, Components

    Renders an uncontrolled <textarea> element that uses a callback function to pass its value to the parent component.

  • Eesolves to useEffect() on the server and useLayoutEffect() on the client.

  • usePrevious

    React, Hooks

    Stores the previous state or props.

  • useTitle

    React, Hooks

    Sets the title of the page

  • useToggler

    React, Hooks

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

  • Mailto

    React, Components

    Renders a link formatted to send an email (mailto: link).

  • useEffectOnce

    React, Hooks

    Runs a callback at most once when a condition becomes true.