question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

react/destructuring-assignment oneliner

See original GitHub issue

Simple and clean oneliner:

  handleClick = () => this.props.firebase.logout();

Right now, I have to write

  handleClick = () => {
    const {firebase} = this.props;
    firebase.logout();
  };

This destructuration is useless in this case. Please remove warnings for oneliner methods where no params are given to the method.

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Reactions:3
  • Comments:7 (3 by maintainers)

github_iconTop GitHub Comments

3reactions
AdrienLemairecommented, Jun 26, 2018
  handleClick () {
    const {firebase} = this.props;
    firebase.logout();
  }

it is, then. Looking forward to the rule, please share it in this issue if you don’t forget about it by then, thanks 😃

1reaction
ljharbcommented, Aug 15, 2018

@jeffvandyke sure. With class fields, you can also do:

foo = this.foo.bind(this);
foo() { }
Read more comments on GitHub >

github_iconTop Results From Across the Web

Destructuring and clone object / One line? - Stack Overflow
I'm using react.js , and I want to obtain from the state an array, but I required to clone it and save it...
Read more >
Destructuring assignment - JavaScript - MDN Web Docs
In this example, f() returns the values [1, 2] as its output, which can be parsed in a single line with destructuring. function...
Read more >
Using destructuring assignment in React - Nathan Sebhastian
Destructuring assignment is a feature of JavaScript introduced by ES6 (or ES 2015) ... You just turned two lines of assignment into one....
Read more >
eslint-plugin-react/destructuring-assignment.md at master
Enforce consistent usage of destructuring assignment of props, state, and context ( react/destructuring-assignment ). This rule is automatically fixable ...
Read more >
Destructuring assignment - The Modern JavaScript Tutorial
Objects allow us to create a single entity that stores data items by key. ... Destructuring assignment is a special syntax that allows...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found