Skip to content

Commit

Permalink
fix(snackbar): fix show animation on new architecture (#4447)
Browse files Browse the repository at this point in the history
  • Loading branch information
seb-zabielski authored Jul 27, 2024
1 parent 4b2052a commit eed911b
Showing 1 changed file with 13 additions and 3 deletions.
16 changes: 13 additions & 3 deletions src/components/Snackbar.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -172,10 +172,9 @@ const Snackbar = ({

const { scale } = theme.animation;

const handleOnVisible = useLatestCallback(() => {
// show
const animateShow = useLatestCallback(() => {
if (hideTimeout.current) clearTimeout(hideTimeout.current);
setHidden(false);

Animated.timing(opacity, {
toValue: 1,
duration: 200 * scale,
Expand All @@ -197,6 +196,11 @@ const Snackbar = ({
});
});

const handleOnVisible = useLatestCallback(() => {
// show
setHidden(false);
});

const handleOnHidden = useLatestCallback(() => {
// hide
if (hideTimeout.current) {
Expand All @@ -214,6 +218,12 @@ const Snackbar = ({
});
});

React.useEffect(() => {
if (!hidden) {
animateShow();
}
}, [animateShow, hidden]);

React.useEffect(() => {
return () => {
if (hideTimeout.current) clearTimeout(hideTimeout.current);
Expand Down

0 comments on commit eed911b

Please sign in to comment.