Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

type specification of prop `systemConfig` is invalid; the type checker function must return `null` or an `Error` but returned a function

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 a is invalid; the type checker function must return null or an Error but 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

like image 803
Mayank Purohit Avatar asked Oct 25 '25 02:10

Mayank Purohit


1 Answers

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),
};
like image 73
Sahil Raj Thapa Avatar answered Oct 26 '25 17:10

Sahil Raj Thapa



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!