can you push a component to an array - react

^^^
1 Reply
Daryl
Daryl2y ago
Hi! Take a look to the documentation: https://react.dev/learn/updating-arrays-in-state# Yeah, you can "add" a Components to an array. I guess your trying to render an array of elements and you're using useState for it. Basically, you don't want to use push or another mutating method. The "react way" is to create a new array and use it to update your state.
Updating Arrays in State – React
The library for web and native user interfaces
Want results from more Discord servers?
Add your server