The snippet library.
Small, practical examples. Search by task or narrow things down below.
Handle a form without navigating
Handle a form without navigating with a small React component and explicit browser behavior.
React✓ Tested
Keep component state with useState
Keep component state with useState with a small React component and explicit browser behavior.
React✓ Tested
Nest a reusable component
Nest a reusable component with a small React component and explicit browser behavior.
React✓ Tested
Pass an object to the style prop
Pass an object to the style prop with a small React component and explicit browser behavior.
React✓ Tested
Pass data through props
Pass data through props with a small React component and explicit browser behavior.
React✓ Tested
Render a list with stable keys
Render a list with stable keys with a small React component and explicit browser behavior.
React✓ Tested
Render an optional notice
Render an optional notice with a small React component and explicit browser behavior.
React✓ Tested
Render nothing from an optional component
Render nothing from an optional component with a small React component and explicit browser behavior.
React✓ Tested
Render your first React component
Render your first React component with a small React component and explicit browser behavior.
React✓ Tested
Supply a default prop value
Supply a default prop value with a small React component and explicit browser behavior.
React✓ Tested
Synchronize the document title with state
Synchronize the document title with state with a small React component and explicit browser behavior.
React✓ Tested
Update an object without mutating state
Update an object without mutating state with a small React component and explicit browser behavior.
React✓ Tested