A
A
Andrey2017-07-02 12:24:47
React
Andrey, 2017-07-02 12:24:47

What is the reason for the prop-types typecheck error?

There is a simple code:

import PropTypes from 'prop-types';

const UsersList = props => (
    <div className="container">
        {props.loading ? '1' : '2'}
    </div>
);

UsersList.propTypes = {
    loading: PropTypes.bool()
};

Error in console:
Calling PropTypes validators directly is not supported by the `prop-types` package. Use `PropTypes.checkPropTypes()` to call them. Read more at fb.me/use-check-prop-types

I followed the link, but I didn’t understand anything: what does he need? Why call checkPropTypes? Why doesn't the perfectly typical and primitive case work?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
Alexey Ukolov, 2017-07-02
@f-end

The typical and primitive case is described as follows:

UsersList.propTypes = {
    loading: PropTypes.bool
};

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question