We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 379da30 commit 59af091Copy full SHA for 59af091
packages/react-native-web/src/exports/Dimensions/index.js
@@ -45,8 +45,14 @@ const dimensions = {
45
};
46
const listeners = {};
47
48
+let shouldInit = canUseDOM;
49
+
50
export default class Dimensions {
51
static get(dimension: DimensionKey): DisplayMetrics {
52
+ if (shouldInit) {
53
+ shouldInit = false;
54
+ Dimensions._update();
55
+ }
56
invariant(dimensions[dimension], `No dimension set for key ${dimension}`);
57
return dimensions[dimension];
58
}
@@ -118,6 +124,5 @@ export default class Dimensions {
118
124
119
125
120
126
if (canUseDOM) {
121
- Dimensions._update();
122
127
window.addEventListener('resize', Dimensions._update, false);
123
128
0 commit comments