Thursday 20 April 2017

Redux store or component state?

Just finishing up my first app with Redux, and really like it. But as I'm going over the whole process at the end here I'm noticing that I drifted back toward using the component state. At first I was putting everything in the store. And that was awesome. Then I started to put little bits of things that I thought really only were relevant to the component on its own in its state. And then slowly more and more stuff started to seem only relevant to individual components and I realized by the end that I was only using the store for user data that needed to be constant throughout all routes.I did, toward the end though, have to put things in the store again that components with totally divergent lineages needed to share. Like if a modal component that was going to pop up and need to change a component beneath it which it wasn't really related to. It felt really hacky but it was the easiest way.To do it again. I'm not sure which way I would go. More heavy on the store, more minimalist on the store. It seems like one approach is definitely just put EVERYTHING in the store. If I were to do this, I'd have some sort of key system that described the component it was about. I'd have a huge store. But then again little things do make sense in the component state though. But then sometimes they end up adding up and drifting toward regular react implementation like my app did. Basically you could put my components on a timeline, the ones more dependent on the store were made first as I was learning the ins and outs of redux, the ones with more internal state were made last as I was... I don't know... regressing?What do you think?

Submitted April 21, 2017 at 01:54AM by L000

No comments:

Post a Comment