© 2026 LinearBytes Inc.
Search posts, tags, users, and pages
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: [] });
Yogesh Chavan
Full Stack Developer | Freelancer | JavaScript | React | Nodejs. https://yogeshchavan.dev/. Book 1:1 @ hiretheauthor.com/myogeshchavan97
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.