Hacker News new | ask | show | jobs
by RubenSandwich 3326 days ago
Redux has a great piece of their tutorial that deals with this problem:

http://redux.js.org/docs/recipes/reducers/BasicReducerStruct....

Here are a few gotchas to avoid:

1. Define your state shape in terms of your domain data and app state, not your UI component tree.

2. Your reducers do not need to have a 1 to 1 mapping to actions. If you need to fire multiple actions to change the data you need then rethink your reducers.

1 comments

"Define your state shape in terms of your domain data and app state, not your UI component tree."

I'm not sure that's what OP is recommending though? In fact, that redux doc seems to me to making an opposite suggestion to the OP -- it seems to be suggesting you should put domain data, app state, and UI state all in the store, but "define your state shape in terms of your domain data and app state, not your UI component tree." OP seems to recommend trying ot keep app state and UI state _out_ of the store if you can.

I think people in practice have a lot of trouble with this, and making it successful, even after experience.

But apparently a lot don't too?