0 votes
in ReactJS by

What is React proptype array with shape?

1 Answer

0 votes
by

If you want to pass an array of objects to a component with a particular shape then use React.PropTypes.shape() as an argument to React.PropTypes.arrayOf().

ReactComponent.propTypes = {
  arrayWithShape: React.PropTypes.arrayOf(React.PropTypes.shape({
    color: React.PropTypes.string.isRequired,
    fontSize: React.PropTypes.number.isRequired
  })).isRequired
}

Related questions

+2 votes
asked Jul 3, 2021 in NumPy by sharadyadav1986
0 votes
asked Nov 4, 2023 in ReactJS by AdilsonLima
...