@tamagui/use-force-update 1.0.0-alpha.64 → 1.0.0-beta.149

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
@@ -2,50 +2,29 @@ var __defProp = Object.defineProperty;
2
2
  var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
3
3
  var __getOwnPropNames = Object.getOwnPropertyNames;
4
4
  var __hasOwnProp = Object.prototype.hasOwnProperty;
5
- var __markAsModule = (target) => __defProp(target, "__esModule", { value: true });
6
5
  var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
7
6
  var __export = (target, all) => {
8
7
  for (var name in all)
9
8
  __defProp(target, name, { get: all[name], enumerable: true });
10
9
  };
11
- var __reExport = (target, module2, copyDefault, desc) => {
12
- if (module2 && typeof module2 === "object" || typeof module2 === "function") {
13
- for (let key of __getOwnPropNames(module2))
14
- if (!__hasOwnProp.call(target, key) && (copyDefault || key !== "default"))
15
- __defProp(target, key, { get: () => module2[key], enumerable: !(desc = __getOwnPropDesc(module2, key)) || desc.enumerable });
10
+ var __copyProps = (to, from, except, desc) => {
11
+ if (from && typeof from === "object" || typeof from === "function") {
12
+ for (let key of __getOwnPropNames(from))
13
+ if (!__hasOwnProp.call(to, key) && key !== except)
14
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
16
15
  }
17
- return target;
16
+ return to;
18
17
  };
19
- var __toCommonJS = /* @__PURE__ */ ((cache) => {
20
- return (module2, temp) => {
21
- return cache && cache.get(module2) || (temp = __reExport(__markAsModule({}), module2, 1), cache && cache.set(module2, temp), temp);
22
- };
23
- })(typeof WeakMap !== "undefined" ? /* @__PURE__ */ new WeakMap() : 0);
18
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
24
19
  var src_exports = {};
25
20
  __export(src_exports, {
26
21
  useForceUpdate: () => useForceUpdate
27
22
  });
23
+ module.exports = __toCommonJS(src_exports);
28
24
  var import_react = require("react");
29
25
  function useForceUpdate() {
30
- const setState = (0, import_react.useState)(0)[1];
31
- const internal = (0, import_react.useRef)();
32
- if (!internal.current) {
33
- internal.current = {
34
- isMounted: true,
35
- update: () => {
36
- if (internal.current.isMounted) {
37
- setState(Math.random());
38
- }
39
- }
40
- };
41
- }
42
- (0, import_react.useEffect)(() => {
43
- return () => {
44
- internal.current.isMounted = false;
45
- };
46
- }, []);
47
- return internal.current.update;
26
+ const [_, forceUpdate] = (0, import_react.useReducer)((x) => x + 1, 0);
27
+ return forceUpdate;
48
28
  }
49
29
  __name(useForceUpdate, "useForceUpdate");
50
- module.exports = __toCommonJS(src_exports);
51
30
  //# sourceMappingURL=index.js.map
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../src/index.ts"],
4
- "sourcesContent": ["import { useEffect, useRef, useState } from 'react'\n\n// ensures no updates after unmount\n\nexport function useForceUpdate() {\n const setState = useState(0)[1]\n const internal = useRef<{ update: Function; isMounted: boolean }>()\n if (!internal.current) {\n internal.current = {\n isMounted: true,\n update: () => {\n if (internal.current!.isMounted) {\n setState(Math.random())\n }\n },\n }\n }\n\n useEffect(() => {\n return () => {\n internal.current!.isMounted = false\n }\n }, [])\n\n return internal.current.update\n}\n"],
5
- "mappings": ";;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA,mBAA4C;AAIrC,0BAA0B;AAC/B,QAAM,WAAW,2BAAS,GAAG;AAC7B,QAAM,WAAW;AACjB,MAAI,CAAC,SAAS,SAAS;AACrB,aAAS,UAAU;AAAA,MACjB,WAAW;AAAA,MACX,QAAQ,MAAM;AACZ,YAAI,SAAS,QAAS,WAAW;AAC/B,mBAAS,KAAK;AAAA;AAAA;AAAA;AAAA;AAMtB,8BAAU,MAAM;AACd,WAAO,MAAM;AACX,eAAS,QAAS,YAAY;AAAA;AAAA,KAE/B;AAEH,SAAO,SAAS,QAAQ;AAAA;AApBV;",
4
+ "sourcesContent": ["import { useReducer } from 'react'\n\nexport function useForceUpdate() {\n const [_, forceUpdate] = useReducer((x) => x + 1, 0)\n return forceUpdate\n}\n"],
5
+ "mappings": ";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,mBAA2B;AAEpB,0BAA0B;AAC/B,QAAM,CAAC,GAAG,eAAe,6BAAW,CAAC,MAAM,IAAI,GAAG,CAAC;AACnD,SAAO;AACT;AAHgB;",
6
6
  "names": []
7
7
  }
package/dist/esm/index.js CHANGED
@@ -1,25 +1,9 @@
1
1
  var __defProp = Object.defineProperty;
2
2
  var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
3
- import { useEffect, useRef, useState } from "react";
3
+ import { useReducer } from "react";
4
4
  function useForceUpdate() {
5
- const setState = useState(0)[1];
6
- const internal = useRef();
7
- if (!internal.current) {
8
- internal.current = {
9
- isMounted: true,
10
- update: () => {
11
- if (internal.current.isMounted) {
12
- setState(Math.random());
13
- }
14
- }
15
- };
16
- }
17
- useEffect(() => {
18
- return () => {
19
- internal.current.isMounted = false;
20
- };
21
- }, []);
22
- return internal.current.update;
5
+ const [_, forceUpdate] = useReducer((x) => x + 1, 0);
6
+ return forceUpdate;
23
7
  }
24
8
  __name(useForceUpdate, "useForceUpdate");
25
9
  export {
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../src/index.ts"],
4
- "sourcesContent": ["import { useEffect, useRef, useState } from 'react'\n\n// ensures no updates after unmount\n\nexport function useForceUpdate() {\n const setState = useState(0)[1]\n const internal = useRef<{ update: Function; isMounted: boolean }>()\n if (!internal.current) {\n internal.current = {\n isMounted: true,\n update: () => {\n if (internal.current!.isMounted) {\n setState(Math.random())\n }\n },\n }\n }\n\n useEffect(() => {\n return () => {\n internal.current!.isMounted = false\n }\n }, [])\n\n return internal.current.update\n}\n"],
5
- "mappings": ";;AAAA;AAIO,0BAA0B;AAC/B,QAAM,WAAW,SAAS,GAAG;AAC7B,QAAM,WAAW;AACjB,MAAI,CAAC,SAAS,SAAS;AACrB,aAAS,UAAU;AAAA,MACjB,WAAW;AAAA,MACX,QAAQ,MAAM;AACZ,YAAI,SAAS,QAAS,WAAW;AAC/B,mBAAS,KAAK;AAAA;AAAA;AAAA;AAAA;AAMtB,YAAU,MAAM;AACd,WAAO,MAAM;AACX,eAAS,QAAS,YAAY;AAAA;AAAA,KAE/B;AAEH,SAAO,SAAS,QAAQ;AAAA;AApBV;",
4
+ "sourcesContent": ["import { useReducer } from 'react'\n\nexport function useForceUpdate() {\n const [_, forceUpdate] = useReducer((x) => x + 1, 0)\n return forceUpdate\n}\n"],
5
+ "mappings": ";;AAAA;AAEO,0BAA0B;AAC/B,QAAM,CAAC,GAAG,eAAe,WAAW,CAAC,MAAM,IAAI,GAAG,CAAC;AACnD,SAAO;AACT;AAHgB;",
6
6
  "names": []
7
7
  }
package/dist/jsx/index.js CHANGED
@@ -1,25 +1,9 @@
1
1
  var __defProp = Object.defineProperty;
2
2
  var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
3
- import { useEffect, useRef, useState } from "react";
3
+ import { useReducer } from "react";
4
4
  function useForceUpdate() {
5
- const setState = useState(0)[1];
6
- const internal = useRef();
7
- if (!internal.current) {
8
- internal.current = {
9
- isMounted: true,
10
- update: () => {
11
- if (internal.current.isMounted) {
12
- setState(Math.random());
13
- }
14
- }
15
- };
16
- }
17
- useEffect(() => {
18
- return () => {
19
- internal.current.isMounted = false;
20
- };
21
- }, []);
22
- return internal.current.update;
5
+ const [_, forceUpdate] = useReducer((x) => x + 1, 0);
6
+ return forceUpdate;
23
7
  }
24
8
  __name(useForceUpdate, "useForceUpdate");
25
9
  export {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tamagui/use-force-update",
3
- "version": "1.0.0-alpha.64",
3
+ "version": "1.0.0-beta.149+a95e53bb",
4
4
  "typings": "types",
5
5
  "main": "dist/cjs",
6
6
  "module": "dist/esm",
@@ -11,10 +11,12 @@
11
11
  ],
12
12
  "scripts": {
13
13
  "build": "tamagui-build",
14
- "watch": "tamagui-build --watch"
14
+ "watch": "tamagui-build --watch",
15
+ "clean": "tamagui-build clean",
16
+ "clean:build": "tamagui-build clean:build"
15
17
  },
16
18
  "devDependencies": {
17
- "@tamagui/build": "^1.0.0-alpha.64"
19
+ "@tamagui/build": "^1.0.0-beta.149+a95e53bb"
18
20
  },
19
21
  "dependencies": {
20
22
  "react": "*"
@@ -22,5 +24,5 @@
22
24
  "publishConfig": {
23
25
  "access": "public"
24
26
  },
25
- "gitHead": "9363f43117f9504de9bd4949ca210cd1ebbf753b"
27
+ "gitHead": "a95e53bb6c4678962ef84a59bf5bac74e7f4f32f"
26
28
  }
package/types/index.d.ts CHANGED
@@ -1,2 +1,3 @@
1
- export declare function useForceUpdate(): Function;
1
+ /// <reference types="react" />
2
+ export declare function useForceUpdate(): import("react").DispatchWithoutAction;
2
3
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAIA,wBAAgB,cAAc,aAqB7B"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";AAEA,wBAAgB,cAAc,0CAG7B"}