Let's now disucss about the UseState().
UseState() is a Hook which store the intial value and update the value if any change occurs in state.
Real life example:
Let's imagine if you go to a restaurant & order noodles. Somehow you changed your mind to try italian. The waiter gave a chance to swap the noodles with pizza.
UseState() is like a waiter. It provides a function to change the initial value assigned.
Usage
The above figure depicts the usage of useState().
On intial render the useState stores 0 as the value.
When user click a button which triggers a function, Inside this function we can call setCount() to update the initial value.
Meet u soon with more concepts in ReactðŸ¤
Top comments (0)