I have an array as non-required property in required object and I want to give a default value for this array.
const { classes, eItem } = props;
eItem: PropTypes.shape({
eList: PropTypes.arrayOf(PropTypes.shape({
id: PropTypes.number.isRequired,
nameSurname: PropTypes.string.isRequired,
img: PropTypes.string,
})),
}).isRequired,
Example.defaultProps = {
eItem: {
eList: []
},
};
I have written defaultProps like that, but I see that eList is undefined in the console.
How can I give a default value for eList as an empty array?