I've been able to solve a lot of my problems by reviewing all the issues here, but what I haven't been able to figure out is a good way to add/remove sections.
Looking at the example, I see you're storing sections in the const CONTENT. I'm wondering if anyone has a recommended way of doing this. Should I be pushing objects to that CONTENT array? Is this in the documentation somewhere and I'm misunderstanding how to do it? I'm new to React so apologies if this is obvious.
I should add that I'm working with the accordion.
You can just keep the content array in your state. As you use setState to add or remove items, the changes will reflect in the accordion
Works perfectly! Thank you!
As someone new to React, I was confused as to why the content array wasn't in the state in the example since I figured that was the "react way" to do things. But I guess if your data isn't changing like in my case, there's not much reason to do so. I do think this behavior would be a cool addition to the example though.
Thanks again for the help and quick response!
Most helpful comment
Works perfectly! Thank you!
As someone new to React, I was confused as to why the content array wasn't in the state in the example since I figured that was the "react way" to do things. But I guess if your data isn't changing like in my case, there's not much reason to do so. I do think this behavior would be a cool addition to the example though.
Thanks again for the help and quick response!