Вы не можете выбрать более 25 тем Темы должны начинаться с буквы или цифры, могут содержать дефисы(-) и должны содержать не более 35 символов.

3 лет назад
12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758
  1. # react-is-deprecated
  2. > Add an `isDeprecated` to your React PropTypes.
  3. ## Install
  4. ```
  5. $ npm install --save react-is-deprecated
  6. ```
  7. ## Usage
  8. `react-is-deprecated` provides two options for wrapping `React.PropTypes`. You can use the `deprecate` function (recommended) to wrap a specific type and output a warning
  9. whenever the prop is defined:
  10. ```js
  11. static propTypes = {
  12. deprecated: deprecate(PropTypes.string, `Your message here`)
  13. }
  14. ```
  15. If you'd like to have an `isDeprecated` function attached to all `React.PropTypes` options you can use `addIsDeprecated`.
  16. ```js
  17. const PropTypes = addIsDeprecated(React.PropTypes);
  18. ...
  19. static propTypes = {
  20. deprecated: PropTypes.object.isDeprecated('Your message here.')
  21. }
  22. ```
  23. **Note: `addIsDeprecated` returns a copy of the passed `PropTypes` instance
  24. and does not mutate the `React.PropTypes`. `isDeprecated` will only work on the PropType object returned.**
  25. ## API
  26. ### `deprecate(propType: React.PropTypes.[type], message: string)`
  27. Returns a function wrapping the `propType` argument with a check to determine if the prop is defined and, if so, log out a warning via `console.warn` once.
  28. ### `addIsDeprecated(input: React.PropTypes)`
  29. Returns an augmented version of `React.PropTypes` with `isDeprecated` added to all top level properties.
  30. ### `[type].isDeprecated(message: string)`
  31. If you use the `addIsDeprecated` function to return a new copy of `React.PropTypes` then each type will have an `isDeprecated` message.
  32. It is identical to `deprecate` with the exception that it is already
  33. bound to the `[type]` and just accepts the message.
  34. ## License
  35. MIT © Brandon Dail