-
Notifications
You must be signed in to change notification settings - Fork 357
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 ability to override isRequired
#339
Comments
If Do you have another example? |
@ljharb, I think you may have missed In that case, it is optional for |
I could still pass |
I feel like maybe we're speaking past each other. I'm trying to figure out a way to make the param mandatory for If you have a recommendation for how to achieve this, I'm all ears. |
This is how: A.propTypes = {
foo: B.propTypes.foo, // required
};
A.defaultProps = {
foo: 'some default'
}; This way, |
When passing props from one component to another, I like to have a single source of truth for my propTypes--the component that actually uses the prop:
In this case, the
foo
property onA
is mandatory...which is great. Well, that is until I want to makefoo
optional onA
because I'm declaring a default value for it:What I'd like to be able to do is override the
isRequired
flag, perhaps like this:If there's some other reasonable way around this problem, I'm all ears.
The text was updated successfully, but these errors were encountered: