React performance

useCallback

Reuses a function reference across eligible updates; it does not invoke that function.

Formal Syntax & Structure

react syntaxreact
useCallback(id => setSelected(old => [...old, id]), [])

Working Example

Example Snippetreact
useCallback(id => setSelected(old => [...old, id]), [])
React Reference