Search posts, tags, users, and pages
Yogesh Chavan
Full Stack Developer | Freelancer | JavaScript | React | Nodejs. https://yogeshchavan.dev/. Book 1:1 @ hiretheauthor.com/myogeshchavan97
In this article, we will see how we can use the new ES6 shorter syntax which will make the setState call a lot simpler. So Let’s start with some background knowledge. Take a look at below arrow function. const getName = () => { return "David"; } The...
Darlan Tódero ten Caten
Entrepreneur & Software Engineer
Good content, I agree and already use the tips in my code.
The last example can be even shorter (and easy to read) because you are not using the prevState:
this.setState({ numbers: [] });
Thank you Darlan Tódero ten Caten.
You're right, the last example can be further simplified as suggested by you because we're not using the previous state value.
Darlan Tódero ten Caten
Entrepreneur & Software Engineer
Good content, I agree and already use the tips in my code.
The last example can be even shorter (and easy to read) because you are not using the prevState:
this.setState({ numbers: [] });