-
Notifications
You must be signed in to change notification settings - Fork 637
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
<UnmountOnAnimatedReaction /> (#5810)
* mount/unmount panels based on visibility * Stall * fix merge * better name * remove the based * UnmountOnAnimatedReaction * lint --------- Co-authored-by: Matthew Wall <[email protected]>
- Loading branch information
1 parent
1d2884c
commit adde11f
Showing
8 changed files
with
143 additions
and
65 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
15 changes: 15 additions & 0 deletions
15
src/__swaps__/screens/Swap/components/UnmountOnAnimatedReaction.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
import { PropsWithChildren, ReactNode, useState } from 'react'; | ||
import { runOnJS, useAnimatedReaction } from 'react-native-reanimated'; | ||
|
||
export function UnmountOnAnimatedReaction({ | ||
isMountedWorklet, | ||
placeholder, | ||
children, | ||
}: PropsWithChildren<{ placeholder: ReactNode; isMountedWorklet: () => boolean }>) { | ||
const [isMounted, setIsMounted] = useState(false); | ||
|
||
useAnimatedReaction(isMountedWorklet, v => runOnJS(setIsMounted)(v)); | ||
|
||
if (isMounted) return children; | ||
return placeholder; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters