Hello, everyone 👋, I hope you are doing great 😊.
So, today you are going to learn all the basic concepts of
useState() Hook, one of the most used Hook in React.
Before you start, there are some rules you need to follow to use Hooks 😟. Thankfully the React Team has provided an ESLint Plugin called eslint-plugin-react-hooks that will help enforce these rules when using Hooks 🤩.
useState() is a Hook. A Hook is a function provided by React that lets you Hook into React features from your functional component.
useState() Hook lets you have a local state in the functional component.
useState() Hook that takes an argument which could be any primitive or non-primitive value and returns an array. The first element of an array is a variable that stores the current state, and the second element of an array is a function that lets you update the current state.
Before we end this article, I want to mentation that you can have more that one
useState() Hook in a functional component.
Now, you have learned all the basic concepts of
useState() Hook 🤘.
Thanks for reading! My name is Bipin Rajbhar; I love helping people to learn new skills 😊. You can follow me on Twitter if you do like to be notified about new articles and resources.