React JS - useState Hook

useState Hook stores the initial state value.

We can update state value on button click.










Output :









useState with Object

We can use useState with object and update state value.

In the following example, the initial value of state object is blank, when user types in input box, the onChange event gets called and the state values gets updated & displayed.























Output :



Comments