jsx-eslint/eslint-plugin-react

react/prop-types doesn't work when mixing createReactClass with ES6 style prop types

Open

#1.663 geöffnet am 28. Jan. 2018

Auf GitHub ansehen
 (5 Kommentare) (0 Reaktionen) (0 zugewiesene Personen)JavaScript (2.797 Forks)batch import
bughelp wanted

Repository-Metriken

Stars
 (8.630 Stars)
PR-Merge-Metriken
 (Keine gemergten PRs in 30 T)

Beschreibung

To facilitate moving to ES6 classes we're mixing createReactClass with ES6 style prop types.

react/prop-types doesn't seem to recognize prop types in this case and reports all used props as "missing in props validation".

File to reproduce:

'use strict';

const createReactClass = require('create-react-class');
const React = require('react');
const PropTypes = require('prop-types');

const Component = createReactClass({
  render: function () {
    return (<div>{this.props.prop}</div>);
  }
});

Component.propTypes = {
  prop: PropTypes.string
};

module.exports = Component;

Contributor Guide