Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add generic PropTypes.objectOf(PropTypes.shape).isRequired #37

Closed
skube opened this issue Jan 28, 2018 · 3 comments
Closed

Add generic PropTypes.objectOf(PropTypes.shape).isRequired #37

skube opened this issue Jan 28, 2018 · 3 comments

Comments

@skube
Copy link

skube commented Jan 28, 2018

Not an issue, more of a possible request...
One PropType we use often, but is not included in this extension, is the generic : PropTypes.objectOf(PropTypes.shape).isRequired

Not sure if it was a conscious decision or if there is some other reason for not including it.

@xabikos
Copy link
Owner

xabikos commented Mar 11, 2018

@skube sorry for my late reply.

Why would you like to do this? In my understanding this is equivalant with
PropTypes.shape({}).isRequired
or am I missing something?

@skube
Copy link
Author

skube commented Mar 11, 2018

I could be wrong, but I think there is a subtle difference as described in this Stack Overflow

@pupretiDev
Copy link

Say we have a case where a prop named 'someProp' is equated as :
someProp= {
dynamickey : {
knownKey1: ,
knownKey2:,
and so on
}
}
Here we do not know the type of dynamic key but we know for sure that its value is an object of all known key types.
Thus to define PropTypes for someProp we may do something like this
someProp: PropTypes.objectOf(PropTypes.shape(
{
knownKey: PropTypes.string,
knownKey2:PropTypes.number
and so on
}
))

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

No branches or pull requests

3 participants