3 Mistakes Every React Beginners Make (are you one of them?)
1. Forget that setState is asynchronous
Even experienced folks forget about that.
Let’s take a look at this example.

Always keep in mind:
setState is async. setState is async. setState is async.
As you can see from the example above we can safely call any function after the state is updated via setState
callback.
setState({ age: value }, () => {
// state is updated and you can safely perfom any action here
})
2. Forget how setState works in functional components
If you’re just starting with React hooks, you can easily forget that setState
here doesn’t work the same way as in the class components.
setState
from class components automatically merges the previous state with the new one.
setState
from functional components don’t do this.

The right way to use setState in functional components is to combine previous state value with the new updates.

3. Using React when you don’t need it
Love this.
Remember: You don’t need ReactJS in most cases.
One page app? Don’t need it.
Blog? Don’t need it.
Large complex app? It depends.
Learn the basics first. And you will understand when and why you need to use React.
In the end
Choose technologies by the problem you try to solve.
Don’t choose something because it’s popular right now.
That’s all. Thanks!
🔴 Get more coding tips, job interview advice, and the latest tech news. Join my Newsletter
Saas Platform Developer, Agiliti Techpartners
Choose technologies by the problem you try to solve. Don’t choose something because it’s popular right now.
Well said!
Comments (3)