@tamagui/use-window-dimensions 1.0.1-beta.189 → 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 CHANGED
@@ -21,6 +21,7 @@ __export(src_exports, {
21
21
  useWindowDimensions: () => useWindowDimensions
22
22
  });
23
23
  module.exports = __toCommonJS(src_exports);
24
+ var import_constants = require("@tamagui/constants");
24
25
  var import_react = require("react");
25
26
  var import_react_native = require("react-native");
26
27
  const initialValue = {
@@ -32,7 +33,7 @@ const initialValue = {
32
33
  function useWindowDimensions() {
33
34
  const [state, setState] = (0, import_react.useState)(initialValue);
34
35
  const current = (0, import_react_native.useWindowDimensions)();
35
- (0, import_react.useLayoutEffect)(() => {
36
+ (0, import_constants.useIsomorphicLayoutEffect)(() => {
36
37
  setState(current);
37
38
  }, [current.height, current.width, current.fontScale, current.scale]);
38
39
  return state;
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../src/index.ts"],
4
- "sourcesContent": ["import { useLayoutEffect, 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 useLayoutEffect(() => {\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,mBAA0C;AAC1C,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,oCAAgB,MAAM;AACpB,aAAS,OAAO;AAAA,EAElB,GAAG,CAAC,QAAQ,QAAQ,QAAQ,OAAO,QAAQ,WAAW,QAAQ,KAAK,CAAC;AAEpE,SAAO;AACT;",
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 { useLayoutEffect, useState } from "react";
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,
@@ -9,7 +10,7 @@ const initialValue = {
9
10
  function useWindowDimensions() {
10
11
  const [state, setState] = useState(initialValue);
11
12
  const current = useWindowDimensionsRN();
12
- useLayoutEffect(() => {
13
+ useIsomorphicLayoutEffect(() => {
13
14
  setState(current);
14
15
  }, [current.height, current.width, current.fontScale, current.scale]);
15
16
  return state;
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../src/index.ts"],
4
- "sourcesContent": ["import { useLayoutEffect, 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 useLayoutEffect(() => {\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,iBAAiB,gBAAgB;AAC1C,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,kBAAgB,MAAM;AACpB,aAAS,OAAO;AAAA,EAElB,GAAG,CAAC,QAAQ,QAAQ,QAAQ,OAAO,QAAQ,WAAW,QAAQ,KAAK,CAAC;AAEpE,SAAO;AACT;",
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.189",
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,10 +18,11 @@
18
18
  "clean:build": "tamagui-build clean:build"
19
19
  },
20
20
  "dependencies": {
21
+ "@tamagui/constants": "^1.0.1-beta.190",
21
22
  "react": "*"
22
23
  },
23
24
  "devDependencies": {
24
- "@tamagui/build": "^1.0.1-beta.189",
25
+ "@tamagui/build": "^1.0.1-beta.190",
25
26
  "@types/react": "^18.0.15",
26
27
  "react-native": "*"
27
28
  },
package/src/index.ts CHANGED
@@ -1,4 +1,5 @@
1
- import { useLayoutEffect, useState } from 'react'
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
  /**
@@ -16,7 +17,7 @@ export function useWindowDimensions() {
16
17
  const [state, setState] = useState(initialValue)
17
18
  const current = useWindowDimensionsRN()
18
19
 
19
- useLayoutEffect(() => {
20
+ useIsomorphicLayoutEffect(() => {
20
21
  setState(current)
21
22
  // eslint-disable-next-line react-hooks/exhaustive-deps
22
23
  }, [current.height, current.width, current.fontScale, current.scale])