fluxxor icon indicating copy to clipboard operation
fluxxor copied to clipboard

Use instanceOf or shape in context types and add propTypes

Open dantman opened this issue 8 years ago • 0 comments

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.

dantman avatar Oct 19 '15 05:10 dantman