Skip to content

Instantly share code, notes, and snippets.

@richardgill
Created December 7, 2017 11:41
Show Gist options
  • Save richardgill/1cfbe54cc775a0d33d4fd5a713bb5af8 to your computer and use it in GitHub Desktop.
Save richardgill/1cfbe54cc775a0d33d4fd5a713bb5af8 to your computer and use it in GitHub Desktop.
Should I put it in Redux?

Should I put it in Redux?

Probably.

Exceptions

1. You want to reuse a component. Put it in multiple projects / put it in NPM.

You don't really want to force other people projects to use redux / setup loads of redux stuff in this case.

2. You're storing very UI / Component related things.

e.g. widths, heights, colours, animation states etc.

Redux is for app stuff, and it's a bit unnecessary to store UI values in there.

3. You'll have many instances of a component

For example you're going to use a component N times in your app, and so storing things N times in various places in redux state just makes it more complicated.

How to use State.

It's often wise to create a component which does the state stuff, and not mix it with out app logic.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment