React Js useState() Hook Example

Hello react js devs in this tutorial i am going to show that how we can use useState() in our functional react component. if we use useState then no need to define your component as class based component. 

It is react hook. So using useState hook we can change our state value easily. If you don't know how react useState hook works then this example is for you to clear your concept.

Basically usestate took three parameters. Initial state, current state and a method. See the below example

const [count, setValue] = useState(0)


Look here 0 is initial state and we used array destructuring to define current state and method. here count is current state and setValue is method. Now in this example we will create a button and when we will click on this button then the value will be incremented. Let's see the example.


Now you can check it to run it browser. Hope it can help you and you've understand react useState hook.


Facebook Github
A web enthusiastic, a self-motivated full-stack software engineer from Dhaka, Bangladesh with experience in developing applications using Laravel , React and Vue js