facebook / prop-types

Runtime type checking for React props and similar objects
MIT License
4.48k stars 356 forks source link

Invalid argument supplied to oneOfType #265

Closed NemanjaManot closed 5 years ago

NemanjaManot commented 5 years ago

I am using Jest, and i got this warning when i am running my tests:

console.error node_modules/prop-types/factoryWithTypeCheckers.js:23 Warning: Invalid argument supplied to oneOfType. Expected an array of check functions, but received undefined at index 2.

Versions:

"react": "^16.8.4",
"react-native": "^0.59.1",
"jest": "^23.6.0",
"babel-jest": "^23.4.2",
"prop-types": "^15.7.2",

Does anyone know that is a problem?

ljharb commented 5 years ago

Looking at that error message, it looks like you’re providing an array to oneOfType whose third item is undefined. Can you share the code that creates that propType?

NemanjaManot commented 5 years ago

For example:

        children: PropTypes.oneOfType([
            PropTypes.arrayOf(PropTypes.node),
            PropTypes.node
        ]).isRequired
        datePickerValue: PropTypes.oneOfType([
            PropTypes.object,
            PropTypes.number,
            PropTypes.string
        ]),
ljharb commented 5 years ago

Both of those look correct; are you sure those are the lines that are erroring?

NemanjaManot commented 5 years ago

I found the error - spelling! @ljharb thank you, you helped me