React: TypeError: checker is not a function at validate

Created on 19 Jun 2015  路  7Comments  路  Source: facebook/react

somehow a weird warning is printed to the console when i have this property

  propTypes:
    links:       React.PropTypes.oneOfType(
      React.PropTypes.object
      React.PropTypes.arrayOf(React.PropTypes.object)
    )

the checkPropTypes() produces

error = TypeError: checker is not a function at validate

at

error = propTypes[propName](props, propName, componentName, location);

and this will print this warning in the console

Warning: Failed propType: checker is not a function Check the render method of `xxx`.

looks like a bug to me ... using React v0.13.3 here

Most helpful comment

just for future reference you can also get this error if a PropType is left incomplete ie.

country: PropTypes

All 7 comments

Can you paste _exactly_ what code you have or make a jsfiddle/jsbin? There are a number of red flags in your code sample (oneOfType takes an array, you're missing commas)

It is valid CoffeeScript syntax

It's valid coffeescript syntax, but it isn't the correct way to invoke oneOfType, as @zpao noted. oneOfType takes an array as it's only argument.

foo(
  bar
  baz
)

desugars to foo(bar, baz), but you want foo([bar, baz]), so you need to write something like

foo [
  bar
  baz
]

instead.

oh right, my bad ... forgot the array syntax.

hmmm, any chance you could add a type check here and throw an error when oneOfType doesn't have an array?

I am facing a similar issue.

Component.propTypes = {
    filter: PropTypes.shape({
        options: {
            openings: PropTypes.arrayOf(
                PropTypes.shape({
                    id: PropTypes.number,
                    name: PropTypes.string
                })
            )
        },
        selected: {
            opening_ids: PropTypes.arrayOf(PropTypes.number),
            candidate_added_date_range: PropTypes.string
        }

    }),
    syncOpeningsFilter: PropTypes.func,
    fetchOpeningsFilterOptions: PropTypes.func.isRequired,
    syncCandidateDateRangeFilter: PropTypes.func
};

Any clue what I might be missing? Thanks in advance :)

EDIT:
http://stackoverflow.com/a/37709854/1939344 helped

Closing as not a common issue, and caused by wrong usage. If it comes up often, feel free to send a PR that adds better warnings.

just for future reference you can also get this error if a PropType is left incomplete ie.

country: PropTypes

Was this page helpful?
0 / 5 - 0 ratings