The React snippet collection contains function components and reusable hooks for React 16.
React, Testing
Testing React components that use portals can be difficult until you understand what you really need to be testing.
React, Components
Renders a table with rows dynamically created from an array of primitives.
React, Hooks
Executes a callback immediately after a component is mounted.
React, Hooks
Executes a callback immediately before a component is unmounted and destroyed.
React, Hooks
Watches for changes made to the DOM tree, using a MutationObserver
React, Components
Renders a password input field with a reveal button.
React, Components
Renders an uncontrolled <textarea>
element that uses a callback function to pass its value to the parent component.
React, Hooks
Implements setTimeout()
in a declarative manner.
React, Hooks
Creates a stateful value with a default fallback if it's null
or undefined
, and a function to update it.
React, Hooks
Implements setInterval()
in a declarative manner.
React, Hooks
Provides a boolean state variable that can be toggled between its two states.
React, Components
Learn the differences between PropTypes.objectOf()
and PropTypes.shape()
and where to use each one with this quick guide.
React, Hooks
Resolves to useEffect()
on the server and useLayoutEffect()
on the client.
React, Hooks
Stores the previous state or props.
React, Components
Renders a link formatted to send an email (mailto:
link).