DEV Community

Discussion on: setState in Reactjs is not a function

Collapse
 
saiavinashiitr profile image
Sai Avinash Duddupudi

The reason I am not using setPerson is because it has be wrapped under useEffect hook but I want to pass this person data to another useState Variables.

Since useState happens in initial load, if we use useEffect I wont be able to pass data to useState variables

Collapse
 
sirseanofloxley profile image
Sean Allin Newell

You still need setPerson. Basically with a functional component using hooks, setState is not defined. Hence your type error.