React useGetSet hook
Creates a stateful value, returning a getter and a setter function.
The React snippet collection contains function components and reusable hooks for React 18.
Creates a stateful value, returning a getter and a setter function.
Wrapping your mind around React hooks and how they interact with setInterval()
can be difficult. Here's a guide to get you started.
Creates a portal, allowing rendering of children outside the parent component.
Testing stateful React components is not difficult, but did you know there's a solution that doesn't involve testing state directly?
Checks if the current environment matches a given media query and returns the appropriate value.
Creates a stateful value, and a function to update it by merging the new state provided.
Checks if the client is online or offline.
Handles the beforeunload
window event.
Renders a list of elements from an array of primitives.
Renders a string as plaintext, with URLs converted to appropriate link elements.
Renders a component with collapsible content.
Testing Redux-connected components is pretty common. Learn how to use this simple utility function to speed up your testing.
In React components, you might need to conditionally apply a className
. Learn how to handle empty values correctly using this handy tip.
Renders a controlled <input>
element that uses a callback function to inform its parent about value updates.
Copies the given text to the clipboard.
Creates a stateful value that is persisted to localStorage
, and a function to update it.
Creates a stateful value that is persisted to sessionStorage
, and a function to update it.
Renders a textarea component with a character limit.
Creates a stateful value from the fields in a form.
Renders a table with rows dynamically created from an array of primitives.
Debounces the given value.
Observes visibility changes for a given element.
Learn of all the different ways to set the value of a selected input in React with this quick guide.
Renders an uncontrolled <input>
element that uses a callback function to inform its parent about value updates.