3
votes

I am getting the warning "Warning: Failed prop type: Invalid prop of type Object supplied to , expected instance of bound checkType."

This is my proptypes:

FieldTable.propTypes = {
    rawData: PropTypes.instanceOf(PropTypes.object).isRequired,
    percentCols: PropTypes.arrayOf(PropTypes.string).isRequired,
    specialColNames: PropTypes.instanceOf(PropTypes.object).isRequired,
    scenarioHeaders: PropTypes.instanceOf(PropTypes.object),
    headerHierarchies: PropTypes.arrayOf(PropTypes.object).isRequired
};

What is this 'bound checkType' it is referring to and how should I be validating my object props to avoid this warning? The objects themselves are JSON objects received from asynchronous calls, and generated in other components.The rawData object, for example, comes from a component that lets the user upload an excel spreadsheet then parses the spreadsheet into a JSON object. Don't know if that's useful information or not.

Thanks for any assistance and especially any deeper discussions that may arise from this question.

2
I should add that I am under string eslint rules so I cannot use simple PropTypes.object.isRequired since that will trigger the react/forbid-prop-types rule.Kaboukie

2 Answers

6
votes

For object when react/forbid-prop-types eslint is enabled, try to use shapes:

plainObj: PropTypes.shape({ subProp: PropTypes.string })
0
votes

To check proptypes of plain JS objects you should use just:

plainObj: PropTypes.object.isRequired,