Tutorial: Handcrafting an Isomorphic Redux Application (With Love)
Milo Mordaunt

Great article. Have a question about React.PropTypes and ImmutableJS on an isomorphic project I am working on.

For example, I have a piece of state/ the redux store called ‘chores’ that is an immutable map with I call into state through a connector. For the PropType validation, I have been using: React.PropTypes.instanceOf(Immutable.Map), which seems to be working fine.

However, when I am in the connected component and do:

const laundry = chores.get(‘laundry’)

The resulting ‘laundry’ variable is showing up as a javascript object, when I am expecting it to be an Immutable object, as fromJS deeply converts JS to Immutable — at least I thought it would?. For example, laundry.isMap() gives an error and typeof(laundry) is an object, so it appears to just be a javascript object.

However, when I pass down ‘laundry’ into a dumb-component and then use PropTypes for laundry as a PropTypes.object, I am having issues (see error below). It also did not work with instanceOf(Immutable.Map). I don’t understand why this is happening and I would like to keep using proptypes.

`Invariant Violation: Element type is invalid: expected a string (for built-in components) or a class/function (for composite components) but got: undefined. Check the render method of <Component>`

If you have any insights, they would be greatly appreciated. Also, I am just curious as to why you did not include PropTypes?

One clap, two clap, three clap, forty?

By clapping more or less, you can signal to us which stories really stand out.