Skip to content

no-did-mount-set-state with arrow functions & React.Component? #1595

Closed
@fohrloop

Description

@fohrloop

Hello,

If I am correct, using no-did-mount-set-state should trigger with the following code:

import React from 'react'

class Test extends React.Component {
  state = {}

  componentDidMount = () => {
    this.setState({
      name: this.props.name.toUpperCase()
    })
  }

  render() {
    return <div>Hello {this.state.name}</div>
  }
}

export default Test

For some reason, I do not get any errors from ESLint. The actual rule I am using is 'react/no-did-mount-set-state': [2, 'disallow-in-func'].

Question

Should the rule trigger with the code above?

System setup

Windows 10, node v.8.9.3, eslint-plugin-react v. 7.5.1, ESLint v.3.19.0 & babel-eslint 8.0.3.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions