Summary
Knowing all the best practices is always a good thing, but sometimes, being aware of anti-patterns helps us avoid taking the wrong path. Most importantly, learning the reasons why some techniques are considered bad practice helps us understand how React works, and how we can use it effectively.
In this chapter, we covered four different ways of using components that can harm the performance and behavior of our web applications.
For each one of those, we used an example to reproduce the problem and supplied the changes to apply in order to fix the issue.
We learned why using properties to initialize the state can result in inconsistencies between the state and the properties. We also saw how using the wrong key
attribute can produce bad effects on the reconciliation algorithm. Finally, we learned why spreading non-standard properties to DOM elements is considered an anti-pattern.
In the next chapter, we will look into the new React Hooks.