Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Problem
Users are seeing a maximum update depth exceeded error when using the VictoryGroup component, specifically when trying to animate it #2708.
I was able to reproduce this in Storybook by rendering the following component:
When the component unmounts (tested in video by switching tab), the error appears.
before.mp4
Solution
The
initialProps
were being reassigned in the body of the component:For some reason, this meant that the linter couldn't detect that
initialProps
is the dependency of auseMemo
, which was revealed when the new object was assigned to a const:To solve this dependency issue, I have wrapped the merging of defaultProps and initialProps in a
![Screenshot 2024-01-16 at 12 17 51](https://private-user-images.githubusercontent.com/9557798/297045664-224fdaa4-bc61-49af-bfea-1d89d3bc40a8.png?jwt=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmF3LmdpdGh1YnVzZXJjb250ZW50LmNvbSIsImtleSI6ImtleTUiLCJleHAiOjE3MzkxODY3ODEsIm5iZiI6MTczOTE4NjQ4MSwicGF0aCI6Ii85NTU3Nzk4LzI5NzA0NTY2NC0yMjRmZGFhNC1iYzYxLTQ5YWYtYmZlYS0xZDg5ZDNiYzQwYTgucG5nP1gtQW16LUFsZ29yaXRobT1BV1M0LUhNQUMtU0hBMjU2JlgtQW16LUNyZWRlbnRpYWw9QUtJQVZDT0RZTFNBNTNQUUs0WkElMkYyMDI1MDIxMCUyRnVzLWVhc3QtMSUyRnMzJTJGYXdzNF9yZXF1ZXN0JlgtQW16LURhdGU9MjAyNTAyMTBUMTEyMTIxWiZYLUFtei1FeHBpcmVzPTMwMCZYLUFtei1TaWduYXR1cmU9YzM4Y2JiYzRjYzE4ZDQwZDk2NTY1ZDAzMDdiZjdhYzQ2Y2MwOTNjOTRmNjlkYTM1NGYyY2JkOTFjNDdkOTA2YyZYLUFtei1TaWduZWRIZWFkZXJzPWhvc3QifQ.mcCHrieR3mp2wxWFGyXw3196NYbjfkzlppUFg8i5B1c)
useMemo
.Working example:
after.mp4