I don’t know about you, but when I started writing React apps, I struggled to decide where my state should go. No matter how I re-arranged setState
calls, things never felt quite right.
And maybe that is why I got so excited when I found Redux. Redux gave me a single place to put all my state. Which sounded great in theory.
But then I realised that having one spot to put things doesn’t necessarily make them easy to get to.
It turns out that I needed more than just a place to put things. I also need a system for putting them in the right place.
For me, that system came from splitting my state into five categories. It turned the problem of deciding “how does this piece of state relate to all the other state”, into the problem of deciding “what type of state is this”. And as it turns out, this is a whole lot easier.