-
-
Notifications
You must be signed in to change notification settings - Fork 70
Closed
Description
I forked minimal example on codesandbox and sligthly changed it: https://codesandbox.io/s/damp-sun-0bhfb1?file=/src/index.js. My goal is to make sure that the lib does prevent re-renders, so I separated render counters for TextBox and Counter components. I would expect their counters to increment independently as I change different parts of the state. But they increase, as if it were a single counter. Also, console.log shows that both componentes are rendered every time the state changes. Am I doing it wrong?
Repro:
- run https://codesandbox.io/s/damp-sun-0bhfb1?file=/src/index.js
- see numRendered1: 2 and numRendered2: 2 (not sure why they are doubled, but let's skip it)
- update Counter by clicking "+1" 3 times
- see numRendered1: 10 and numRendered2: 2 (the 1st counter should be 8, and this is also because they depend on each other)
- update TextBox by adding 1 symbol to "hello" (like "hello+")
Expectation:
- see numRendered1: 10 and numRendered2: 4 (I would say it should be 8/4, but let's pay attention to 4-12 difference)
Result:
- numRendered1: 10 and numRendered2: 12
Metadata
Metadata
Assignees
Labels
No labels