React Core & Hooks (407 Qs)•General
What is React proptype array with shape?
junior LevelCode ExampleData Structures
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
import PropTypes from 'prop-types';
ReactComponent.propTypes = {
arrayWithShape: PropTypes.arrayOf(
PropTypes.shape({
color: PropTypes.string.isRequired,
fontSize: PropTypes.number.isRequired,
})
).isRequired,
};