So, I'm trying to add a shape to my component objects. The object is loaded from the server, so it is not there from the very beginning. But when I add the form to Proptypes. He continues to throw an error so that it is marked as required, but it is not.
automatically adds shapeor objectOfvalue isRequired?
TopicsList.propTypes = {
topicsObject: PropTypes.shape(reportsTopicsObjectResultShape),
};
And the figures:
export const reportsTopicObject = PropTypes.shape({
avg_rating_ord: PropTypes.number,
cards_with_comments: PropTypes.number,
cards_without_comments: PropTypes.number,
number_of_questions: PropTypes.number,
rating_count: PropTypes.number,
scale_version_id: PropTypes.string,
scale_id: PropTypes.string,
last_answered_at: PropTypes.string,
id: PropTypes.string,
type: PropTypes.string,
name: PropTypes.shape(translatedObjectSystem),
description: PropTypes.shape(translatedObjectSystem)
});
export const reportsTopicsObjectResultShape = PropTypes.shape({
topics_distribution: PropTypes.shape({
general: PropTypes.number,
groups: PropTypes.number,
people: PropTypes.number
}),
topic_list: PropTypes.objectOf(reportsTopicObject)
});
I'm still getting an error
Failed prop type: The prop `topicsObject.isRequired` is marked as
required in `TopicsList`, but its value is `undefined`.
It is true that at the beginning of undefined this is normal, but I do not want this to be required
source
share