r/reactjs • u/dance2die • Oct 01 '20
Needs Help Beginner's Thread / Easy Questions (October 2020)
Previous Beginner's Threads can be found in the wiki.
Ask about React or anything else in its ecosystem :)
Stuck making progress on your app?
Still Ask away! Weβre a friendly bunch.
No question is too simple. π
Want Help with your Code?
Improve your chances of reply by
adding minimal example with JSFiddle, CodeSandbox, or Stackblitz links
describing what you want it to do (ask yourself if it's an XY problem)
things you've tried. (Don't just post big blocks of code!)
Formatting Code wiki shows how to format code in this thread.
Pay it forward! Answer questions even if there is already an answer. Other perspectives can be helpful to beginners. Also, there's no quicker way to learn than being wrong on the Internet.
New to React?
Check out the sub's sidebar! π
π Here are great, free resources!
Read the official Getting Started page on the docs.
New to Hooks? Check out Amelia Wattenberger's Thinking in React Hooks
and these React Hook recipes on useHooks.com by Gabe Ragland
What other updated resources do you suggest?
Any ideas/suggestions to improve this thread - feel free to comment here!
Finally, thank you to all who post questions and those who answer them. We're a growing community and helping each other only strengthens it!
3
u/Awnry_Abe Oct 04 '20
Is there a reason you don't just create a new array in the state setter using something like the spread operator?
return [...prevState]
Short of that, you need to make react aware of each individual array item, or employ a state toggle hack. const [hack, setHack] = useState(1);
....setArray(...); setHack((h) => h+1);