I am doing proptype check in my React.js code like this
const { a, b ,c } = this.props
where a, b, c are my objects or response coming from API
and in my propTypes check my code look's like
ComponentName.propTypes = {
a: PropTypes.objectOf,
b: PropTypes.objectOf,
c: PropTypes.objectOf,
};
in Default PropTypes assigning it like this
ComponentName.defaultProps = {
a: {
key1: '',
key2: '',
},
b: {
key3: '',
key4: '',
},
},
But when i am compiling my code it is giving me this error
type specification of prop
ais invalid; the type checker function must returnnullor anErrorbut returned a function. You may have forgotten to pass an argument to the type checker creator (arrayOf, instanceOf, objectOf, oneOf, oneOfType, and shape all require an argument)
Please can someone help in removing this warning from the console what can be the workaround
Use PropTypes.any for value of any data type
ComponentName.propTypes = {
a: PropTypes.objectOf(PropTypes.any),
b: PropTypes.objectOf(PropTypes.any),
c: PropTypes.objectOf(PropTypes.any),
};
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With