No. It won't work that way. setState() cannot be called with React hooks.
const [person, setPerson] = useState([])
In the state hook method, the second parameter (in this case setPerson) is what is used to change/update the state.
Now instead of setState(data), do setPerson(data) and it should work just fine.
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
No. It won't work that way. setState() cannot be called with React hooks.
const [person, setPerson] = useState([])
In the state hook method, the second parameter (in this case setPerson) is what is used to change/update the state.
Now instead of setState(data), do setPerson(data) and it should work just fine.
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
You still need setPerson. Basically with a functional component using hooks, setState is not defined. Hence your type error.