InterviewHubPRO
Section Overview
Q58

Question 58 of 445

Part 1: Core React, JSX & Component Architecture (1 - 77)

13%
React & Modern Frontend (445 Qs)•Part 1: Core React, JSX & Component Architecture (1 - 77)

What is React proptype array with shape?

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().

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