LoginSignup
1
0

More than 1 year has passed since last update.

React.jsのPropTypes.array の役割

Last updated at Posted at 2022-03-22

配列を受け付ける

PropTypes.array

// 受け付けるもの
[33, 'こんにちわ', true]
[{ name: '山田'}, { fruit: 'りんご' }]

配列であれば中身は気にしない。
そのため非推奨となっている。

配列の値の型もすべてチェックするなら、 arrayOfを使用する必要がある。

PropTypes.arrayOf(PropTypes.string) 

// 受け付けるもの
['1','あいうえお']

参考
React.jsでPropTypesを利用した時の話

1
0
1

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
1
0