React State Errors¶
- Welcome into state section, in this section we will explore examples of errors which can happen when working with states in react, we will explore hook used react which includes from the beginner level to intermediate.Before you dive into this section I think it will be best if you know the rules of each state which you are using into your component.
useState¶
- Into this section `useState` hook we will explore what is useState, what are the rules of react useState, when to use it and possible solution to react useState errors,
## use State Rules - **Call hooks at the top level**.Don't call hooks inside the condition or function, or nested functions it's a bad practice.import { useState } from "react";
Here are some of the erros you can encounter when working with react useState
1: **Parsing error**: This occurs when you created a state for a certain object may be blog title but you have redeclared into your program example:const [blogTitle, setBlogTitle] = useState("");
const [blogTitle, setBlogTitle] = useState("");