News for hackers. Stuff that matters.
Re:React 16 by acemarke on Tuesday September 26, 2017 @09:30PM (#15344181)
I wrote an article a while back that describes some of the possible benefits for using Redux in a React app: https://www.fullstackreact.com/articles/redux-with-mark-erik... .

Quick summary: you don't have to pass data as props all the way from the top of your app to the bottom, and it lets you keep your app state if you're doing hot module reloading in development.

In addition, time-travel debugging and the action history log really are powerful tools for understanding how your app is behaving over time.

My other comment just below this discusses some more benefits, and links to Dan's "You Might Not Need Redux" post. I'd encourage you to read that as well.

Re:React 16 by rand_r on Tuesday September 26, 2017 @11:08PM (#15344622)
> you don't have to pass data as props all the way from the top of your app to the bottom

Quick note, you can accomplish this directly using the "context" feature of React, which is what Redux uses under the hood anyway.

https://facebook.github.io/react/docs/context.html

Re:React 16 by acemarke on Tuesday September 26, 2017 @11:40PM (#15344746)
Yeah, I was keeping the explanation shorter.

The React docs generally advise that apps try not to use context directly, as the API has limitations, and _will_ change in some future React release once they figure out a better approach. The main issue is that context updates are blocked if a component returns `false` from `shouldComponentUpdate` (and the same for a PureComponent). As a result, context is best suited for references that won't change, such as pubsub event emitters.

Michel Weststrate's post "How to safely use React context" [0] is excellent, and Ken Wheeler just gave a good talk about context at React Boston [1].

[0] https://medium.com/@mweststrate/how-to-safely-use-react-cont...

[1] http://reactboston.surge.sh/#/

Re:React 16 by worldsayshi on Wednesday September 27, 2017 @03:17AM (#15345564)
As someone who went from using context to using redux, you can really shoot yourself in the foot with contexts. With redux we can breath again.

Contexts is useful for anything that rarely changes. Like callbacks. But if you want to send down stateful things it will quickly become a mess for complex apps.