Skip to content

prop-types doesn't check nextProps of componentWillReceiveProps #814

Closed
singapore/lint-condo
#240
@Eschon

Description

@Eschon

This is kind of related to #801 but as far as I can tell the PR to fix (#792) it doesn't fix my issue. I modified the reproduction case from #801 there to show my issue:

import React, {PropTypes} from "react";

export default React.createClass({

  propTypes: {
    bar: PropTypes.func,
  },

  componentWillReceiveProps (nextProps) {
    if (nextProps.foo) { // this line should trigger the 'prop-types' rule but doesn't
      return;
    }
  },

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

Activity

mqklin

mqklin commented on Jan 8, 2018

@mqklin

@yannickcr seems like it isn't fixed:
react/prop-types doesn't warn if I get props from nextProps
image

In this case there should be an Error about x as well.

@Eschon did you resolve the issue?

ljharb

ljharb commented on Jan 8, 2018

@ljharb
Member

Since this is from a year ago, could you file a new issue for your use case?

mqklin

mqklin commented on Jan 8, 2018

@mqklin

Yes, today I'll do it

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

      Development

      Participants

      @ljharb@mqklin@Eschon

      Issue actions

        prop-types doesn't check nextProps of componentWillReceiveProps · Issue #814 · jsx-eslint/eslint-plugin-react