perf(ui): do not re-animate drawer on re-render, reduce useEffects #12743
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.
Previously, every time the drawer re-rendered a new entry animation may be triggered. This PR fixes this by setting the open state to
modalState[slug]?.isOpen
instead offalse
.Additionally, I was able to simplify this component while maintaining functionality. Got rid of one
useEffect
and oneuseState
call. The remaining useEffect also runs less often (previously, it ran every timemodalState
changed => it re-ran if any modal opened or closed, not just the current one)