Skip to content

no-unused-prop-types doesn't check nextProps of componentWillReceiveProps #801

Closed
@bywo

Description

@bywo

If a prop is only used in the context of nextProps, the lint rule mistakenly thinks that the prop is never used.

Here's a repro case:

import React, {PropTypes} from "react";

export default React.createClass({

  propTypes: {
    foo: PropTypes.bool, // this line gets flagged when it shouldn't
    bar: PropTypes.func,
  },

  componentWillReceiveProps (nextProps) {
    if (nextProps.foo) {
      return;
    }
  },

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions