I’m trying to update the person which i get the data from people [array] let [person, setPeople] = useState(people);
why if I make this setPeople(person[0]) not work
I just a beginner in react and i know that’s a stupid question but i’m trying to explore
I tried to undertstand why it just take the whole person not an index but i can’t
2
Answers
You have to decide if your state should contains one person or all people.
In your code You mixed it.
e.g. that would be okey:
Also in 99.9% of times You should use const for state instead of let.
It would be great, if we had a minimal-reproducible-example
Please find below a simple useState example, hope this helps. 🙂