Early return?
See original GitHub issueThis should be error right?
if (thing) {
return;
}
const [state, setState] = useState(null);
Issue Analytics
- State:
- Created 5 years ago
- Comments:16 (6 by maintainers)
Top Results From Across the Web
Return Early Pattern - Medium
R eturn early is the way of writing functions or methods so that the expected positive result is returned at the end of...
Read more >Are Early Returns Any Good? - Better Programming
The idea behind returning early is that you write functions that return the expected positive result at the end of the function.
Read more >The early return pattern in JavaScript - Go Make Things
With the early return pattern, you check for the opposite of the thing you want, and return early to end the function when...
Read more >Should I return from a function early or use an if statement?
Early return if there is some obvious dead end condition to check for right away that would make running the rest of the...
Read more >Return early - DEV Community
An early return, or “return early” is an approach to keep readability in functions and methods. It is always considered a wise choice...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Right, that is correct 👍 Thanks for pointing it out! This is a very interesting case that I did not think of beforehand.
I will try to cover this case in the nearest future
Good news 😄 I just published
tslint-react-hooks@2.0.0-alpha.1
that reports violations for hooks used after early returns.You can install it with:
I am looking for your opinions 😄 Let me know if it works fine for you after installing the latest alpha.
If everything is good, I will release 2.0.0 to the public