Hooks

Custom Hook contract

Share stateful behavior through a use-prefixed function; each call has its own state unless explicitly sharing an external owner.

Formal Syntax & Structure

react syntaxreact
function useFeature() { /* Hooks */ }

Working Example

Example Snippetreact
function useToggle() { return useState(false); }
React Reference