UNPKG

@attio/react-native-bottom-sheet-toolbox

Version:
35 lines (30 loc) 1.12 kB
import React from "react" import {useBottomSheetToolboxInternalContext} from "../../context" import {BOTTOM_SHEET_DEV_TOOLS} from "../../utils" export function useBottomSheetDevToolsInitialSheet() { const { currentPositionSharedValue, normalizedSnapPointsSharedValue, wrapperHeightSharedValue, isReadySharedValue, debugId, } = useBottomSheetToolboxInternalContext() const sendSheetMessage = React.useCallback(() => { BOTTOM_SHEET_DEV_TOOLS.sendMessage("upsert-sheet", { currentPosition: currentPositionSharedValue.get(), snapPoints: normalizedSnapPointsSharedValue.get(), wrapperHeight: wrapperHeightSharedValue.get(), isReady: isReadySharedValue.get(), sheetId: debugId, }) }, [ currentPositionSharedValue, debugId, isReadySharedValue, normalizedSnapPointsSharedValue, wrapperHeightSharedValue, ]) React.useEffect(() => { BOTTOM_SHEET_DEV_TOOLS.addMessageListener("did-connect", sendSheetMessage) }, [sendSheetMessage]) }