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.

Linter complains when using arrow function for refs

See original GitHub issue

I’m using arrow function for refs as explained in the docs here: https://facebook.github.io/react/docs/more-about-refs.html

but the linter complains with this:

217:54 warning Arrow function should not return assignment

Is there an issue with the way the docs describe how to use arrow functions with refs? Should the docs be updated?

Issue Analytics

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

github_iconTop GitHub Comments

11reactions
vjeuxcommented, Aug 31, 2016

You are probably writing

<TextInput ref={(c) => this._input = c} />

if you add {} around the function body it should remove the warning:

<TextInput ref={(c) => { this._input = c; }} />
3reactions
gaearoncommented, Aug 31, 2016

Fixed via #529, will be out in the next version. Thanks!

Read more comments on GitHub >

github_iconTop Results From Across the Web

Arrow function should not return assignment? - Stack Overflow
My code is working correctly in the app however, my eslint isn't liking it and is saying I should not return assignment. What...
Read more >
arrow-body-style - ESLint - Pluggable JavaScript Linter
A pluggable and configurable linter tool for identifying and reporting on patterns in JavaScript. Maintain your code quality with ease.
Read more >
Common React TypeScript ESLint / Lint Errors & Warning ...
The lint messages: Arrow function should not return assignment warning. In case we want to return an assignment but our code is using...
Read more >
ESLint v2.0.0-rc.1 released - ESLint中文文档
There was an additional condition that had been part of no-arrow-condition incorrectly, which checked for the use of arrow functions in conditional ...
Read more >
@sailshq/eslint | Yarn - Package Manager
An AST-based pattern checker for JavaScript. ast, lint, javascript, ecmascript. readme. @sailshq/eslint. A fork of eslint v4.
Read more >

github_iconTop Related Medium Post

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