fix(snackbar): fix show animation on new architecture #4447
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.
Motivation
This bug is only available on android with new architecture enabled and is well described (with and example) in the related issue #4445
From what I've been able to find, the problem occurs when the animation is started before the component is rendered.
In our scenario, the component returns null as long as the
hidden
state is set to true. In thehandleOnVisible
function we have the main stepssetHidden(false)
and Animation start. To fix the bug, I moved the start of the animation to a useEffect that depends on thehidden
value, so that the animation will start after the state is changed (and component re-rendered).btw, since this bug only occurs with the new architecture, it is either also a react-native bug or an expected change. I have not found an answer yet.
Related issue
#4445
Test plan
Run android app with New Architecture enabled and try to show/hide snackbar.
Screen.Recording.2024-07-01.at.09.47.14.mov
Screen.Recording.2024-07-01.at.09.44.12.mov