Closed mnm364 closed 5 years ago
PropType warnings fail tests, when tests are set up properly. Adding .isDeprecated
here would constitute the same as restrictedProp
from https://npmjs.com/airbnb-prop-types - a breaking change, disallowing the prop entirely.
Hmmm, that is a fair point and thanks for the quick repy! Is there no conceivable way to allow rules to pass tests but still warn in production? Out of curiosity, do you know how airbnb-prop-types handles this in their testing suite?
No, no reliable way i can think of, since all propTypes warnings go out the same channel.
There are no hard deprecations internally; the prop usually has a replacement ship as a minor, then a codemod is done, and then the old one is removed as a major.
@mnm364 you might want to check this library, https://github.com/thefrontside/deprecated-prop-type, for the false-positive on props.
Woot! Okay, thanks guys for all the input. Appreciate it and your time. Will close this issue out.
Do you want to request a feature or report a bug? Request a feature
What is the current behavior? N/A
What is the expected behavior? N/A
Which versions of React, and which browser / OS are affected by this issue? Did this work in previous versions of React? N/A
I find myself in a position of inheriting a few React components that have wide usage within the organization I work in. I would like to safely change the name of a few prop types and do so in an incremental manner.
To that end, would it be possible to support an
isDeprecated
check that can be chained alongside other type checks to throw warnings to users of the deprecated props? For example, consider thepropTypes
That we want to migrate to
To advertise this so as to incrementally allow users of this component to migrate independently of the change, I would like to do something like the following,
Such that supplying the
name
prop would always generate a warning.I know I can write my own custom validator -- which is great! -- but I would think others would find this useful as builtin library functionality as well.
If given the green light, I would be happy to take a look into submitting a PR for this.