fixes backdrop flash when content height is increasing
Motivation
This PR fixes https://github.com/gorhom/react-native-bottom-sheet/issues/436.
The culprit of the issue was a sudden drop in animatedIndex because of the height change, so the approach is to detect if the animatedIndex achieved max value already (ie backdrop appeared fully) and then interpolate only if animatedIndex values start to decrease.
Another important topic is how to render the backdrop itself. The doc suggests something like that:
const renderBackdrop = useCallback(
(props: BottomSheetBackdropProps) => (
<BottomSheetBackdrop {...props} />
),
[]
);
which, surprisingly, causes flicker sometimes because react unmounts and mounts the backdrop on height changes. The fix is to add key prop:
const renderBackdrop = useCallback(
(props: BottomSheetBackdropProps) => (
<BottomSheetBackdrop key="backdrop" {...props} />
),
[]
);
Video
https://user-images.githubusercontent.com/25742/128371308-4359284b-1ddc-4114-9a23-6c839b118ed0.mp4
This PR is stale because it has been open 30 days with no activity. Remove stale label or comment or this will be closed in 10 days.
@gorhom commenting as soon as this is still mergeable
i will look into this pr this weekend, thanks for submitting it @somebody32
@gorhom ping
@gorhom ping
I still have this problem in the latest version (v4).
If I have multiple bottom sheets inside a screen and a TextInput not inside any of the bottom sheets blurs, the animated index changes for a split second and the backdrop flashes.
Any ideas? @somebody32
@somebody32 anyway to integrate this fix till it gets merged?
This PR is way out of date and should probably be closed.