diff --git a/index.d.ts b/index.d.ts index 5b7ecdb..c25ba1a 100644 --- a/index.d.ts +++ b/index.d.ts @@ -86,12 +86,12 @@ interface RBSheetProps { /** * Callback function that will be called after the bottom sheet has been opened. */ - onOpen?: () => void; + onOpen?: (openArgs?:any) => void; /** * Callback function that will be called after the bottom sheet has been closed. */ - onClose?: () => void; + onClose?: (closeArgs?:any) => void; /** * Your own compoent. @@ -103,12 +103,12 @@ interface RBSheetRef { /** * The method to open bottom sheet. */ - open: () => void; + open: (openArgs?:any) => void; /** * The method to close bottom sheet. */ - close: () => void; + close: (closeArgs?:any) => void; } declare const RBSheet: React.ForwardRefExoticComponent< diff --git a/src/index.js b/src/index.js index 912a18f..2c4afcb 100644 --- a/src/index.js +++ b/src/index.js @@ -40,8 +40,8 @@ const RBSheet = forwardRef((props, ref) => { // Exposing component methods to parent via useImperativeHandle hook useImperativeHandle(ref, () => ({ - open: () => handleSetVisible(true), - close: () => handleSetVisible(false), + open: (openArgs) => handleSetVisible(true, openArgs), + close: (closeArgs) => handleSetVisible(false, closeArgs), })); // Function to create PanResponder @@ -83,12 +83,12 @@ const RBSheet = forwardRef((props, ref) => { const panResponder = useRef(createPanResponder()).current; // Function to handle the visibility of the modal - const handleSetVisible = visible => { + const handleSetVisible = (visible, otherParams=undefined) => { if (visible) { setModalVisible(visible); // Call onOpen callback if provided if (typeof onOpen === 'function') { - onOpen(); + onOpen(otherParams); } // Animate height on open Animated.timing(animatedHeight, { @@ -108,7 +108,7 @@ const RBSheet = forwardRef((props, ref) => { pan.setValue({x: 0, y: 0}); // Call onClose callback if provided if (typeof onClose === 'function') { - onClose(); + onClose(otherParams); } }); }