Skip to content
This repository has been archived by the owner on Sep 1, 2024. It is now read-only.

Validating if the arguments passed to oneOf is not a function #36

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions factoryWithTypeCheckers.js
Original file line number Diff line number Diff line change
Expand Up @@ -277,6 +277,15 @@ module.exports = function(isValidElement, throwOnDirectAccess) {
return emptyFunction.thatReturnsNull;
}

function isValueAFunction(value) {
return typeof value === 'function'
}

if (expectedValues.every(isValueAFunction)) {
process.env.NODE_ENV !== 'production' ? warning(false, 'Invalid argument supplied to oneOf, expected an array of values but got an array of PropType functions. Did you mean oneOfType?') : void 0;
return emptyFunction.thatReturnsNull;
}

function validate(props, propName, componentName, location, propFullName) {
var propValue = props[propName];
for (var i = 0; i < expectedValues.length; i++) {
Expand Down