State

Initial prop versus current state

A prop supplied as the initial useState value does not automatically update already mounted local state.

Formal Syntax & Structure

react syntaxreact
const [open, setOpen] = useState(initiallyOpen);

Working Example

Example Snippetreact
const [note, setNote] = useState(initialNote);
React Reference