Skip to content

destructuring-assignment in class properties #1875

Closed
@alexandernanberg

Description

@alexandernanberg

First I'd like to just say that I like the new destructuring-assignment rule because I think it enforces a lot more clarity and explicitness. However I'm having problems with it throwing errors inside of class properties.

class MyComponent extends React.Component {
  state = {
    value: this.props.defaultValue,
  };

  ...
}

IMO this should be an exception and be totally valid or at least have the option to exclude it just from this use-case. I know that I could move it inside a constructor and destructure it there but I'd rather not do that.

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