Skip to content

Instantly share code, notes, and snippets.

@ryankshaw
Last active August 29, 2015 14:23
Show Gist options
  • Save ryankshaw/485d5d0d28de85f32285 to your computer and use it in GitHub Desktop.
Save ryankshaw/485d5d0d28de85f32285 to your computer and use it in GitHub Desktop.

It only means that your component is not "pure". as in, the same "state" and "props" can result in different html since render "reads data from store". I try to have as many components "pure" as possible, meaning their entire interface to the outside world is props & state--easier to reason about, cleaner, easier to test.

could you have something higher up--either a "higher order component" (if you've never heard that term, see: google.com/search?q=react+higher+order+components) or some non-component glue code--do the subscribing and pass the data you need down to you as "props".

but yeah, sometimes you gotta do what you gotta do. maybe this is that higher order component. I wouldn't have a whole lot of components doing this but if this is the one that has to, I'd have it up as high as possible in herarchy and have it do something like store.onChange(this.forceUpdate)

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