diff --git a/packages/components/src/mobile/bottom-sheet/sub-sheet/index.native.js b/packages/components/src/mobile/bottom-sheet/sub-sheet/index.native.js index 8654dc918e2e3d..f51b07cffd9c14 100644 --- a/packages/components/src/mobile/bottom-sheet/sub-sheet/index.native.js +++ b/packages/components/src/mobile/bottom-sheet/sub-sheet/index.native.js @@ -6,8 +6,8 @@ import { SafeAreaView } from 'react-native'; /** * WordPress dependencies */ -import { Children, useEffect } from '@wordpress/element'; -import { createSlotFill, BottomSheetConsumer } from '@wordpress/components'; +import { Children, useEffect, useContext } from '@wordpress/element'; +import { createSlotFill, BottomSheetContext } from '@wordpress/components'; const { Fill, Slot } = createSlotFill( 'BottomSheetSubSheet' ); @@ -17,26 +17,19 @@ const BottomSheetSubSheet = ( { showSheet, isFullScreen, } ) => { - const BottomSheetScreen = ( { onMount } ) => { - useEffect( onMount, [] ); - return children ?? null; - }; + const { setIsFullScreen } = useContext( BottomSheetContext ); + + useEffect( () => { + if ( showSheet ) { + setIsFullScreen( isFullScreen ); + } + }, [ showSheet, isFullScreen ] ); return ( <> { showSheet && ( - - - { ( { setIsFullScreen } ) => ( - - setIsFullScreen( isFullScreen ) - } - /> - ) } - - + { children } ) } { Children.count( children ) > 0 && navigationButton }