useState
Syntax
Where:
const [state,setState]
: Return ofuseState
, the arguments allow reading and updating of the state associated with the hook instance.state
: Current state.setState
: Current status updater.
useState( optionalInitialState )
: Function that associates the state to the webcomponent:optionalInitialState
: Optional parameter that defines the initial state associated to the hook instance, IfoptionalInitialState
is a function it will be executed in order to obtain the initial state only at the moment of the hook instance for the first time.
Example
Last updated