from Hacker News

React, Automatic Redux Providers, and Replicators

by tfb on 2/14/16, 1:57 PM with 4 comments

  • by tfb on 2/14/16, 2:14 PM

    There seem to be a lot of similar questions about how to reduce redux's boilerplate and build something real-world with it. I think I found a pretty good solution (among other things) which I wrote about within this article.

    TL;DR: You can create redux providers that automatically match themselves to your components based on their propTypes. All you really need is a components directory, a providers directory, and an optional but recommended themes directory. Everything is easily interchangeable, understandable, maintainable, extendable, and reusable. There's a lot more included with all that like hot reloading both client and server, server rendering, etc., etc., etc. I built an app from scratch based on the included boilerplate yesterday and it took about 10 minutes as opposed to the 1 hour it would usually take!

  • by ivan_ah on 2/14/16, 5:13 PM

    Very interesting write-up. Definitely cuts down on the boilerplate.

    Would be good to explain what `react-redux-provide` does under the hood. It might help convince redux users that the package is doing some of the work for them.

    Also what would the code look like without the @provide decorator? [Stick to ES6, it's already crazy enough, no need to jump to ES7 stuff]