React useMergeState hook
Creates a stateful value, and a function to update it by merging the new state provided.
The React snippet collection contains function components and reusable hooks for React 18.
Creates a stateful value, and a function to update it by merging the new state provided.
Creates a portal, allowing rendering of children outside the parent component.
Executes a callback whenever the window is resized.
Creates a stateful value that is persisted to localStorage
, and a function to update it.
Checks if the client is online or offline.
Creates a stateful value that is persisted to sessionStorage
, and a function to update it.
Handles the beforeunload
window event.
Debounces the given value.
Creates a stateful value from the fields in a form.
Observes visibility changes for a given element.
Copies the given text to the clipboard.
Checks if the current environment matches a given media query and returns the appropriate value.
Implements setTimeout()
in a declarative manner.
Creates an error dispatcher.
Implements setInterval()
in a declarative manner.
Executes a callback immediately after a component is mounted.
Executes a callback immediately before a component is unmounted and destroyed.
Avoid unnecessary re-runs by using primitive dependencies in your React effect.
Creates a stateful value with a default fallback if it's null
or undefined
, and a function to update it.
Runs a callback at most once when a condition becomes true.
Resolves to useEffect()
on the server and useLayoutEffect()
on the client.
Sets the title of the page
Provides a boolean state variable that can be toggled between its two states.
Stores the previous state or props.