@tamagui/use-window-dimensions 1.0.1-beta.188 → 1.0.1-beta.190
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cjs/index.js +7 -3
- package/dist/cjs/index.js.map +2 -2
- package/dist/esm/index.js +7 -3
- package/dist/esm/index.js.map +2 -2
- package/package.json +3 -3
- package/src/index.ts +10 -3
package/dist/cjs/index.js
CHANGED
|
@@ -21,7 +21,8 @@ __export(src_exports, {
|
|
|
21
21
|
useWindowDimensions: () => useWindowDimensions
|
|
22
22
|
});
|
|
23
23
|
module.exports = __toCommonJS(src_exports);
|
|
24
|
-
var
|
|
24
|
+
var import_constants = require("@tamagui/constants");
|
|
25
|
+
var import_react = require("react");
|
|
25
26
|
var import_react_native = require("react-native");
|
|
26
27
|
const initialValue = {
|
|
27
28
|
fontScale: 1,
|
|
@@ -30,9 +31,12 @@ const initialValue = {
|
|
|
30
31
|
scale: 1
|
|
31
32
|
};
|
|
32
33
|
function useWindowDimensions() {
|
|
34
|
+
const [state, setState] = (0, import_react.useState)(initialValue);
|
|
33
35
|
const current = (0, import_react_native.useWindowDimensions)();
|
|
34
|
-
|
|
35
|
-
|
|
36
|
+
(0, import_constants.useIsomorphicLayoutEffect)(() => {
|
|
37
|
+
setState(current);
|
|
38
|
+
}, [current.height, current.width, current.fontScale, current.scale]);
|
|
39
|
+
return state;
|
|
36
40
|
}
|
|
37
41
|
// Annotate the CommonJS export names for ESM import in node:
|
|
38
42
|
0 && (module.exports = {
|
package/dist/cjs/index.js.map
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../src/index.ts"],
|
|
4
|
-
"sourcesContent": ["import {
|
|
5
|
-
"mappings": ";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,
|
|
4
|
+
"sourcesContent": ["import { useIsomorphicLayoutEffect } from '@tamagui/constants'\nimport { useState } from 'react'\nimport { ScaledSize, useWindowDimensions as useWindowDimensionsRN } from 'react-native'\n\n/**\n * SSR safe useWindowDimensions\n */\n\nconst initialValue: ScaledSize = {\n fontScale: 1,\n height: 800,\n width: 600,\n scale: 1,\n}\n\nexport function useWindowDimensions() {\n const [state, setState] = useState(initialValue)\n const current = useWindowDimensionsRN()\n\n useIsomorphicLayoutEffect(() => {\n setState(current)\n // eslint-disable-next-line react-hooks/exhaustive-deps\n }, [current.height, current.width, current.fontScale, current.scale])\n\n return state\n}\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,uBAA0C;AAC1C,mBAAyB;AACzB,0BAAyE;AAMzE,MAAM,eAA2B;AAAA,EAC/B,WAAW;AAAA,EACX,QAAQ;AAAA,EACR,OAAO;AAAA,EACP,OAAO;AACT;AAEO,SAAS,sBAAsB;AACpC,QAAM,CAAC,OAAO,QAAQ,QAAI,uBAAS,YAAY;AAC/C,QAAM,cAAU,oBAAAA,qBAAsB;AAEtC,kDAA0B,MAAM;AAC9B,aAAS,OAAO;AAAA,EAElB,GAAG,CAAC,QAAQ,QAAQ,QAAQ,OAAO,QAAQ,WAAW,QAAQ,KAAK,CAAC;AAEpE,SAAO;AACT;",
|
|
6
6
|
"names": ["useWindowDimensionsRN"]
|
|
7
7
|
}
|
package/dist/esm/index.js
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { useIsomorphicLayoutEffect } from "@tamagui/constants";
|
|
2
|
+
import { useState } from "react";
|
|
2
3
|
import { useWindowDimensions as useWindowDimensionsRN } from "react-native";
|
|
3
4
|
const initialValue = {
|
|
4
5
|
fontScale: 1,
|
|
@@ -7,9 +8,12 @@ const initialValue = {
|
|
|
7
8
|
scale: 1
|
|
8
9
|
};
|
|
9
10
|
function useWindowDimensions() {
|
|
11
|
+
const [state, setState] = useState(initialValue);
|
|
10
12
|
const current = useWindowDimensionsRN();
|
|
11
|
-
|
|
12
|
-
|
|
13
|
+
useIsomorphicLayoutEffect(() => {
|
|
14
|
+
setState(current);
|
|
15
|
+
}, [current.height, current.width, current.fontScale, current.scale]);
|
|
16
|
+
return state;
|
|
13
17
|
}
|
|
14
18
|
export {
|
|
15
19
|
useWindowDimensions
|
package/dist/esm/index.js.map
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../src/index.ts"],
|
|
4
|
-
"sourcesContent": ["import {
|
|
5
|
-
"mappings": "AAAA,SAAS,
|
|
4
|
+
"sourcesContent": ["import { useIsomorphicLayoutEffect } from '@tamagui/constants'\nimport { useState } from 'react'\nimport { ScaledSize, useWindowDimensions as useWindowDimensionsRN } from 'react-native'\n\n/**\n * SSR safe useWindowDimensions\n */\n\nconst initialValue: ScaledSize = {\n fontScale: 1,\n height: 800,\n width: 600,\n scale: 1,\n}\n\nexport function useWindowDimensions() {\n const [state, setState] = useState(initialValue)\n const current = useWindowDimensionsRN()\n\n useIsomorphicLayoutEffect(() => {\n setState(current)\n // eslint-disable-next-line react-hooks/exhaustive-deps\n }, [current.height, current.width, current.fontScale, current.scale])\n\n return state\n}\n"],
|
|
5
|
+
"mappings": "AAAA,SAAS,iCAAiC;AAC1C,SAAS,gBAAgB;AACzB,SAAqB,uBAAuB,6BAA6B;AAMzE,MAAM,eAA2B;AAAA,EAC/B,WAAW;AAAA,EACX,QAAQ;AAAA,EACR,OAAO;AAAA,EACP,OAAO;AACT;AAEO,SAAS,sBAAsB;AACpC,QAAM,CAAC,OAAO,QAAQ,IAAI,SAAS,YAAY;AAC/C,QAAM,UAAU,sBAAsB;AAEtC,4BAA0B,MAAM;AAC9B,aAAS,OAAO;AAAA,EAElB,GAAG,CAAC,QAAQ,QAAQ,QAAQ,OAAO,QAAQ,WAAW,QAAQ,KAAK,CAAC;AAEpE,SAAO;AACT;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@tamagui/use-window-dimensions",
|
|
3
|
-
"version": "1.0.1-beta.
|
|
3
|
+
"version": "1.0.1-beta.190",
|
|
4
4
|
"types": "./types/index.d.ts",
|
|
5
5
|
"main": "dist/cjs",
|
|
6
6
|
"module": "dist/esm",
|
|
@@ -18,11 +18,11 @@
|
|
|
18
18
|
"clean:build": "tamagui-build clean:build"
|
|
19
19
|
},
|
|
20
20
|
"dependencies": {
|
|
21
|
-
"@tamagui/
|
|
21
|
+
"@tamagui/constants": "^1.0.1-beta.190",
|
|
22
22
|
"react": "*"
|
|
23
23
|
},
|
|
24
24
|
"devDependencies": {
|
|
25
|
-
"@tamagui/build": "^1.0.1-beta.
|
|
25
|
+
"@tamagui/build": "^1.0.1-beta.190",
|
|
26
26
|
"@types/react": "^18.0.15",
|
|
27
27
|
"react-native": "*"
|
|
28
28
|
},
|
package/src/index.ts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { useIsomorphicLayoutEffect } from '@tamagui/constants'
|
|
2
|
+
import { useState } from 'react'
|
|
2
3
|
import { ScaledSize, useWindowDimensions as useWindowDimensionsRN } from 'react-native'
|
|
3
4
|
|
|
4
5
|
/**
|
|
@@ -13,7 +14,13 @@ const initialValue: ScaledSize = {
|
|
|
13
14
|
}
|
|
14
15
|
|
|
15
16
|
export function useWindowDimensions() {
|
|
17
|
+
const [state, setState] = useState(initialValue)
|
|
16
18
|
const current = useWindowDimensionsRN()
|
|
17
|
-
|
|
18
|
-
|
|
19
|
+
|
|
20
|
+
useIsomorphicLayoutEffect(() => {
|
|
21
|
+
setState(current)
|
|
22
|
+
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
23
|
+
}, [current.height, current.width, current.fontScale, current.scale])
|
|
24
|
+
|
|
25
|
+
return state
|
|
19
26
|
}
|