HurricaneJames / react-immutable-proptypes

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

Using specific Record type as PropType #19

Closed delenius closed 8 years ago

delenius commented 8 years ago

Suppose I am using Immutable.Record to define my own types, say

var Person = Immutable.Record({age: null, name: null})

is it possible to specify that a prop has to be an instance of my Person type, rather than just "Immutable.PropTypes.record"? This would be a big win for type-checking and documentation.

zerkms commented 8 years ago

I initially expected that ImmutablePropTypes.recordOf(Person) would do the job, but apparently it does not.

So I'm doubling having it.

HurricaneJames commented 8 years ago

Sorry for taking so long to look at this. I recently moved to California to start a new job and have been caught up in all the stuff that goes with moving and changing jobs. I will look at this over the weekend.

HurricaneJames commented 8 years ago

I think you can just use the default React.PropTypes.instanceOf(Person), right?

delenius commented 8 years ago

@HurricaneJames yeah you're right :+1: Feel free to close this.