It’s funny how things that make you cringe and yell at your screen at first, can also make you fall in love into them. I guess good ideas are pretty much like women. When I go back and think about the first time I saw React, it was pretty much like that: Inline html with js? Are you kidding me?! Why would I go through the trouble?! Virtual DOM, properties, states? How is that stuff supposed to make development simpler?! What the hell is wrong with this world?! But then, that hunch of brilliance would just keep nagging you to further explore these crazy ideas and why they just might work. And the end result is that you not only learn to appreciate the tech, you start loving it.
Now, the one problem with React that people were trying to solve since they learned to love it is: now what? How do we connect it with our data and handle it with minimal boilerplate? I was skeptical about Flux from day one but see that’s the difference: I hated React when I saw it, but I was just kinda skeptical about Flux. It’s much harder to grow out of skepticism into a romance. You can have a sort of a steady relationship with no frills with that kind of start, but nothing close to real romance. There were too many questions lingering (how many stores, how do I organize and track them? Why so much code to connect them? Do I store anything on a component or not, what about change tracking? etc…) and you were pretty much left on your own to answer them. If you searched for an explanation or best practices, the general answer would be “it depends”. And I must admit, the whole ambiguity about “The right way”TM also cooled down my love for React.
A few days ago I ran into what seem to me as just-another-flux-also-ran called Redux. But after reading about it, I actually hated it. It seemed to simple and dumbed down, and introduced ideas like single state storage. This post started 2 weeks ago as a rant about sorry state of Flux and especially about Redux as a extremely stupid solution for the problem. But the same thing that happened with React, happened with Redux. The ideas clicked and love was born. Now there are a lot of good articles and videos about Redux, so I won’t go into explaining the details. It’s actually pretty simple pub-sub system but scalable. The boilerplate is minimized but flexibility is still there, and it delivers on one thing I had trouble with other Flux solutions: simple implementation of single source of truth (without huge amount of hooks and boilerplate). It’s so good that even some developers of competing solutions stopped developing their own and switched. It’s also under development at break-neck speed (it changed from v1 to v2 in 2 weeks) and the support and documentation is awesome. It still needs some questions answered and stuff tweaked but I expect it to become a de-facto standard for development of React application. Check out Dan Abramov’s video about Redux:
and the Redux github. Oh, and as an added plus, check out my sample application built with React and Redux