The snippet library.
Small, practical examples. Search by task or narrow things down below.
Append to an array without mutating state
Append to an array without mutating state with a small React component and explicit browser behavior.
React✓ Tested
Assign a CSS class in JSX
Assign a CSS class in JSX with a small React component and explicit browser behavior.
React✓ Tested
Calculate a value inside JSX
Calculate a value inside JSX with a small React component and explicit browser behavior.
React✓ Tested
Choose between two render branches
Choose between two render branches with a small React component and explicit browser behavior.
React✓ Tested
Compose content through children
Compose content through children with a small React component and explicit browser behavior.
React✓ Tested
Control a checkbox
Control a checkbox with a small React component and explicit browser behavior.
React✓ Tested
Control a select element
Control a select element with a small React component and explicit browser behavior.
React✓ Tested
Control a text input
Control a text input with a small React component and explicit browser behavior.
React✓ Tested
Disable an unavailable action
Disable an unavailable action with a small React component and explicit browser behavior.
React✓ Tested
Display a JavaScript value in JSX
Display a JavaScript value in JSX with a small React component and explicit browser behavior.
React✓ Tested
Group siblings with a fragment
Group siblings with a fragment with a small React component and explicit browser behavior.
React✓ Tested
Handle a button click
Handle a button click with a small React component and explicit browser behavior.
React✓ Tested