Eslint-plugin-react: react/prop-types said missing in props validation while use stateless component.

Created on 10 Jan 2017  路  2Comments  路  Source: yannickcr/eslint-plugin-react

I've wrote stateless component and props validation like this.

const BusDistance = ({ line }) => (
    <div className="box">
        <article className="media">
            <div className="media-left">
                <div style={styles.circleBusLine} className="red-bg">
                    <h1>{line}</h1>
                </div>
            </div>
            <div className="media-content">
                <h1>2 KM</h1>
            </div>
        </article>
    </div>
);

BusDistance.PropTypes = {
    line: PropTypes.number.isRequired,
};

And ESLint said.

screen shot 2560-01-10 at 2 50 22 pm

Please clarify me how to make a props validation with stateless component.

Thank you.

invalid question

Most helpful comment

Glancing over this quickly, it seems that BusDistance.PropTypes should be BusDistance.propTypes, that is 鈥撀爌ropTypes must start with a lowercase p. This should resolve your problem.

All 2 comments

Glancing over this quickly, it seems that BusDistance.PropTypes should be BusDistance.propTypes, that is 鈥撀爌ropTypes must start with a lowercase p. This should resolve your problem.

@hugihlynsson Problem Solved! Thank you :)

Was this page helpful?
0 / 5 - 0 ratings