State Management in Pure React with Hooks: useState

bipinrajbhar

Bipin Rajbhar

Posted on April 8, 2020

State Management in Pure React with Hooks: useState

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 Hook

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.

Example

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.

πŸ’– πŸ’ͺ πŸ™… 🚩
bipinrajbhar
Bipin Rajbhar

Posted on April 8, 2020

Join Our Newsletter. No Spam, Only the good stuff.

Sign up to receive the latest update from our blog.

Related