diff --git a/packages/vibrant-core/src/lib/WindowDimensionsProvider/WindowDimensionsProvider.native.tsx b/packages/vibrant-core/src/lib/WindowDimensionsProvider/WindowDimensionsProvider.native.tsx index f5059548c..353b66778 100644 --- a/packages/vibrant-core/src/lib/WindowDimensionsProvider/WindowDimensionsProvider.native.tsx +++ b/packages/vibrant-core/src/lib/WindowDimensionsProvider/WindowDimensionsProvider.native.tsx @@ -1,39 +1,6 @@ import type { FC, ReactElement } from 'react'; -import { createContext, useCallback, useContext, useMemo, useState } from 'react'; -import type { LayoutChangeEvent } from 'react-native'; -import { Dimensions, View } from 'react-native'; -import type { WindowDimensionsContextValue } from './WindowDimensionsProviderProps'; +import { useWindowDimensions as useReactNativeWindowDimensions } from 'react-native'; -const WindowDimensionsContext = createContext({ - width: 0, - height: 0, -}); +export const WindowDimensionsProvider: FC<{ children: ReactElement }> = ({ children }) => children; -export const WindowDimensionsProvider: FC<{ children: ReactElement }> = ({ children }) => { - const [width, setWidth] = useState(() => Dimensions.get('window').width); - const [height, setHeight] = useState(() => Dimensions.get('window').height); - - const onLayout = useCallback((event: LayoutChangeEvent) => { - setWidth(event.nativeEvent.layout.width); - - setHeight(event.nativeEvent.layout.height); - }, []); - - const contextValue = useMemo( - () => ({ - width, - height, - }), - [height, width] - ); - - return ( - - - {children} - - - ); -}; - -export const useWindowDimensions = () => useContext(WindowDimensionsContext); +export const useWindowDimensions = () => useReactNativeWindowDimensions();