The snippet library.
Small, practical examples. Search by task or narrow things down below.
Focus an input through a ref
Focus an input through a ref with a small React component and explicit browser behavior.
React✓ Tested
Keep a mutable value without rendering on each write
Keep a mutable value without rendering on each write with a small React component and explicit browser behavior.
React✓ Tested
Observe when a DOM node is attached
Observe when a DOM node is attached with a small React component and explicit browser behavior.
React✓ Tested
Open and close a native dialog
Open and close a native dialog with a small React component and explicit browser behavior.
React✓ Tested
Read an uncontrolled field through a ref
Read an uncontrolled field through a ref with a small React component and explicit browser behavior.
React✓ Tested
Remember the previously committed value
Remember the previously committed value with a small React component and explicit browser behavior.
React✓ Tested
Scroll a referenced element into view
Scroll a referenced element into view with a small React component and explicit browser behavior.
React✓ Tested
Select the contents of an input
Select the contents of an input with a small React component and explicit browser behavior.
React✓ Tested
Store and cancel a timer handle
Store and cancel a timer handle with a small React component and explicit browser behavior.
React✓ Tested