-
-
Notifications
You must be signed in to change notification settings - Fork 50
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
Deprecated PropType #14
Comments
Since responsible apps make console warnings fail tests, that would cause deprecated propTypes to fail tests. |
We could use |
That's fair. All of our propTypes have |
Been thinking about that. The most I came up with is either a no-op, or it sets required on the 1st argument PropType. |
The latter makes the most sense to me - but the concept of a required deprecated propType might not make sense at all, given that if it's required, you can't migrate off of it. |
@ljharb e.g. consider a scenario where a Component currently has an SomeComponent.propTypes = {
onChange: PropTypes.func.isRequired
}; for various reasons it is decided to rename this prop to import { func } from 'prop-types';
const upgrade = mutuallyExclusiveProps(func, 'onChange', 'onValueChange');
SomeComponent.propTypes = {
onValueChange: upgrade
onChange: deprecated(upgrade)
}; Then once we've finally removed the deprecated property we can go back to the same as before: SomeComponent.propTypes = {
onValueChange: PropTypes.func.isRequired
}; |
Sure, that's a reasonable pattern. However, I'd compose propTypes and make one of |
A new PropType for denoting a prop as deprecated would be useful in slowly migrating components. It would simply call
console.warn
in non-production and pass through the original PropType.Something like the following:
The text was updated successfully, but these errors were encountered: