MCPcopy Create free account
hub / github.com/gorhom/react-native-bottom-sheet / StackExample

Function StackExample

example/src/screens/modal/StackExample.tsx:13–137  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

11import { withModalProvider } from './withModalProvider';
12
13const StackExample = () => {
14 // hooks
15 const { dismiss, dismissAll } = useBottomSheetModal();
16
17 // refs
18 const bottomSheetModalARef = useRef<BottomSheetModal>(null);
19 const bottomSheetModalBRef = useRef<BottomSheetModal>(null);
20 const bottomSheetModalCRef = useRef<BottomSheetModal>(null);
21
22 // variables
23 const snapPoints = useMemo(() => ['25%', '50%'], []);
24
25 // callbacks
26 const handlePresentAPress = useCallback(() => {
27 if (bottomSheetModalARef.current) {
28 bottomSheetModalARef.current.present();
29 }
30 }, []);
31 const handleDismissAPress = useCallback(() => {
32 if (bottomSheetModalARef.current) {
33 bottomSheetModalARef.current.dismiss();
34 }
35 }, []);
36 const handlePresentBPress = useCallback(() => {
37 if (bottomSheetModalBRef.current) {
38 bottomSheetModalBRef.current.present();
39 }
40 }, []);
41 const handleDismissBPress = useCallback(() => {
42 if (bottomSheetModalBRef.current) {
43 bottomSheetModalBRef.current.dismiss();
44 }
45 }, []);
46 const handlePresentCPress = useCallback(() => {
47 if (bottomSheetModalCRef.current) {
48 bottomSheetModalCRef.current.present();
49 }
50 }, []);
51 const handleDismissCPress = useCallback(() => {
52 if (bottomSheetModalCRef.current) {
53 bottomSheetModalCRef.current.dismiss();
54 }
55 }, []);
56 const handleDismissAllPress = useCallback(() => {
57 dismissAll();
58 }, [dismissAll]);
59 const handleDismissByHookPress = useCallback(() => {
60 dismiss('A');
61 }, [dismiss]);
62
63 // renders
64 const renderHeaderHandle = useCallback(
65 (title: string) => (props: BottomSheetHandleProps) => (
66 <HeaderHandle {...props}>{title}</HeaderHandle>
67 ),
68 []
69 );
70 const renderBottomSheetContent = useCallback(

Callers

nothing calls this directly

Calls 3

presentMethod · 0.80
dismissMethod · 0.80
useBottomSheetModalFunction · 0.50

Tested by

no test coverage detected