PropTypes in reaction + redux

in redux examples, I see something like this:

Footer.propTypes = {
  completedCount: PropTypes.number.isRequired,
  activeCount: PropTypes.number.isRequired,
  filter: PropTypes.string.isRequired,
  onClearCompleted: PropTypes.func.isRequired,
  onShow: PropTypes.func.isRequired
}

So what do these PropTypes really do? Are they enjoyable or must-have?

thank

+4
source share
2 answers

As finalFreq pointed out, I am correcting! "The above example will work fine in future response versions. It will respond to obsolescence by calling the proptypes function directly, but annotating the component will work very well in current and future versions."

( ), ( typescript proptypes), , . ! , , , . , , . js .

FlowType: https://flowtype.org/docs/getting-started.html#_

, - . , flowtype IMHO. - , ().

: , proptypes .

+2

propTypes , . , , , , .

.isRequired, , , . , , , .

, , , . , , , , - .

0

Source: https://habr.com/ru/post/1658746/


All Articles