HurricaneJames / react-immutable-proptypes

PropType validators that work with Immutable.js.
MIT License
642 stars 46 forks source link

Experimental implementation for recordOf(Type) #20

Closed zerkms closed 8 years ago

zerkms commented 8 years ago

This is just a POC implementation for #19

As you may spot to check if it's a plain-old JS object I'm using the ugly

if (recordKeys.constructor !== Object) {

check.

That is necessary since at the moment there is no (?) way to check if a custom type is an instance of the Immutable.Record. For that I sent a feature request: https://github.com/facebook/immutable-js/issues/775

Any thoughts?

HurricaneJames commented 8 years ago

As I said in #19, I will take a look at this over the weekend. Thank you for the contribution.

HurricaneJames commented 8 years ago

I just left a comment in #19. I think you can accomplish the same thing with React.PropTypes.instanceOf(). I just tried building out a sample implementation, and it seems to work fine.

zerkms commented 8 years ago

If so - it would be a solution indeed.