You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
ReactUse **deliberately avoids memoizing** hook methods by default. This decision is based on several important principles of React application development.
6
+
7
+
## About optimization
8
+
9
+
> "Premature optimization is the root of all evil" β Donald Knuth
10
+
11
+
Memoization is an optimization technique, and like any optimization, it should be applied consciously when there's a real performance problem. Automatic memoization of all functions can:
12
+
13
+
-**Hide real architectural problems** β instead of fixing the root cause of unnecessary re-renders, we mask the symptoms
14
+
-**Create a false sense of security** β developers might think performance is already optimized
15
+
-**Complicate debugging** β memoized functions don't behave as expected when dependencies change
16
+
17
+
## Re-renders are normal
18
+
19
+
React is designed so that component re-renders are a natural and efficient part of its operation. Modern browsers and React Fiber can handle a lot of re-renders without noticeable impact on performance.
20
+
21
+
Memoization is a tool that should be in the hands of the application developer, not the library.
The React team is working on **React Compiler** β a tool that will automatically optimize your code by adding memoization where it's truly needed.
46
+
47
+
When React Compiler becomes stable, the question of manual memoization will become less relevant, but the principles of conscious optimization will remain important.
0 commit comments