Skip to content

Conversation

@defcc
Copy link
Member

@defcc defcc commented Oct 9, 2016

the getType func only returns the first prop type, even if the prop type is an array.

Add getTypeList func to get prop types.
fix #3879

let value = propsData[key]
// handle boolean props
if (getType(prop.type) === 'Boolean') {
if (getTypeList(prop.type).indexOf('Boolean') >= 0) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Since this function is pretty perf-sensitive, I'd suggest a isBooleanType(prop.type) function that:

  • If prop.type is Array, iterate with for and return if any equals 'Boolean'
  • otherwise just check === 'Boolean'.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

thanks, got it

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Multi-type prop validation is not consistent

3 participants