Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

static defaultProps breaks prefer-stateless-function #1521

Closed
evandavis opened this issue Nov 8, 2017 · 1 comment
Closed

static defaultProps breaks prefer-stateless-function #1521

evandavis opened this issue Nov 8, 2017 · 1 comment

Comments

@evandavis
Copy link

The following is not caught by prefer-stateless-function:

import React from 'react';
import PropTypes from 'prop_types';

export default class Thing extends React.Component {
  static defaultProps = {
     foo: ''
  };

  static propTypes = {
    foo: PropTypes.string
  };

  render() {
    return <div>{this.props.foo}</div>;
  }
}

However, by removing static defaultProps, the error is reported:

import React from 'react';
import PropTypes from 'prop_types';

export default class Thing extends React.Component {
  static propTypes = {
    foo: PropTypes.string
  };

  render() {
    return <div>{this.props.foo}</div>;
  }
}

This is happening in 7.4.0.

@ljharb
Copy link
Member

ljharb commented Nov 8, 2017

Thanks for the report!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Development

No branches or pull requests

2 participants