import { Dimensions, PixelRatio, View } from 'react-native';
const rem = (value) => {
const { width, height, fontScale } = Dimensions.get('window');
const pixelRatio = PixelRatio.get();
const baseRem = width / 100;
const adjustedRem = baseRem * pixelRatio * fontScale;
return value * adjustedRem;
};
const MyComponent = () => {
return (
<View>
<View style={{ width: rem(50), height: rem(50), backgroundColor: 'red' }} />
<View style={{ width: rem(100), height: rem(100), backgroundColor: 'blue' }} />
<View style={{ width: rem(150), height: rem(150), backgroundColor: 'green' }} />
</View>
);
};
export default MyComponent;