react-native-full-responsive
Version:
Create a fully responsive React Native app for all supported platforms
17 lines (12 loc) • 475 B
text/typescript
import { useMemo } from 'react';
import { rw } from '../layout';
import { MaybeNumber } from 'src/types';
import { useWindowDimensions } from 'react-native';
const useResponsiveWidth = (widthPercentage: MaybeNumber) => {
const { width: screenWidth } = useWindowDimensions();
const width = useMemo(() => {
return rw(widthPercentage, screenWidth);
}, [screenWidth, widthPercentage]);
return width;
};
export { useResponsiveWidth, useResponsiveWidth as useRW };