import { useState } from 'react'; import { ViewProps } from 'react-native'; export const useMaxLayoutWidth = () => { const [maxLayoutWidth, setMaxLayoutWidth] = useState(0); const handleLayout: ViewProps['onLayout'] = (event) => { const { width } = event.nativeEvent.layout; setMaxLayoutWidth(Math.max(width, maxLayoutWidth)); }; const resetMaxLayoutWidth = () => { setMaxLayoutWidth(0); }; return { maxLayoutWidth, handleLayout, resetMaxLayoutWidth }; };