til

How to get proper screen dimensions

javascriptreact-native

Samsung devices have some sort of resolution selection that will make width and height returned from Dimensions.get("window") not to work as expected. To avoid it, we have to use this scaling factor:

const { width, height } = Dimensions.get("window");

const scaleFactor =
  Dimensions.get("screen").scale / Dimensions.get("window").scale;

export const screenWidth = width * scaleFactor;
export const screenHeight = height * scaleFactor;