fac19 / Cardley

Cardley the flash card app
https://cardley.netlify.app
0 stars 0 forks source link

State Management #76

Open Joepock123 opened 4 years ago

Joepock123 commented 4 years ago

Sorry for the late issue but just popped into my head.

Did you have many problems setting and lifting state in your app? It seems like you didn't have to pass too many props down and the code is clean. We found React's useContext pretty helpful for managing state in one place. It's like a toned down version on Redux but from what I hear sufficient for most smaller projects.

Roger-Heathcote commented 4 years ago

@Joepock123 There was definitely was, and to some extent still is, a lot of confusion about managing state. One issue was making sure or useEfffects ran when we wanted them to, and didn't when we didn't. That was how we managed to DDOS our own server! I think I've got a grip on that now but I'm deliberately ignoring our linter warnings about missing items in our dependencies arrays so I might be using an anti-pattern there. It seems to work though so I'll take that until I become more enlightened! The other thing that was unclear was when, where and how to reset states optimally. There's so much more to learn about React. I don't know about you but I still feel like I'm fighting it more than it's helping me. Clearly I've got a few conceptual voids to fill before it really clicks!

Thanks a lot for the tip about useContext too, that's very cool! I def could have made use of that in this last project and I'm certain we'll use it in this upcoming one.