React.PropTypes array with specific length

后端 未结 4 1501
一向
一向 2021-02-19 22:05

Is it possible to use React.PropTypes to enforce length\'s on an array?

Here is a very simple case:

const TWO_NUMBERS = PropTypes.array; // i          


        
4条回答
  •  忘掉有多难
    2021-02-19 23:02

    PropTypes checks for types not for attributes. Also, checking for PropTypes is disabled in production mode. That makes it impossible for PropTypes to check for ever changing array lengths during run-time.

提交回复
热议问题