fluxxor
fluxxor copied to clipboard
Use instanceOf or shape in context types and add propTypes
I recently had to track down a fairly cryptic error:
this.getFlux(...).store is not a function
Short story, this error was the result of accidentally passing a promise that resolves to a Fluxxor.Flux
instance instead of an actual instance.
I think Fluxxor should do a little more to ensure it is actually working with Fluxxor.Flux
instances. Namely instead of using React.PropTypes.object
for flux
I think it should explicitly make sure that it is a Flux
object.
Depending on your stance on cross-realm/multiple-instance handling this can either be done by using React.PropTypes.instanceOf
or using a React.PropTypes.shape
that looks for the telltale parts of a Flux
object like store
, stores
, etc...
Likewise I think the FluxMixin
should also declare propTypes
for the props it uses.