@tamagui/use-force-update 1.0.0-alpha.12
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/LICENSE +21 -0
- package/dist/cjs/index.js +50 -0
- package/dist/cjs/index.js.map +7 -0
- package/dist/esm/index.js +28 -0
- package/dist/esm/index.js.map +7 -0
- package/dist/index.cjs +52 -0
- package/dist/index.cjs.map +7 -0
- package/dist/index.js +28 -0
- package/dist/index.js.map +7 -0
- package/dist/jsx/index.js +27 -0
- package/package.json +27 -0
- package/src/index.d.ts +1 -0
- package/src/index.d.ts.map +1 -0
- package/src/index.js +21 -0
- package/src/index.ts +26 -0
- package/types/index.d.ts +2 -0
- package/types/index.d.ts.map +1 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2020 Nate Wienert
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
var __create = Object.create;
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
6
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
7
|
+
var __markAsModule = (target) => __defProp(target, "__esModule", { value: true });
|
|
8
|
+
var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
|
|
9
|
+
var __export = (target, all) => {
|
|
10
|
+
__markAsModule(target);
|
|
11
|
+
for (var name in all)
|
|
12
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
13
|
+
};
|
|
14
|
+
var __reExport = (target, module2, desc) => {
|
|
15
|
+
if (module2 && typeof module2 === "object" || typeof module2 === "function") {
|
|
16
|
+
for (let key of __getOwnPropNames(module2))
|
|
17
|
+
if (!__hasOwnProp.call(target, key) && key !== "default")
|
|
18
|
+
__defProp(target, key, { get: () => module2[key], enumerable: !(desc = __getOwnPropDesc(module2, key)) || desc.enumerable });
|
|
19
|
+
}
|
|
20
|
+
return target;
|
|
21
|
+
};
|
|
22
|
+
var __toModule = (module2) => {
|
|
23
|
+
return __reExport(__markAsModule(__defProp(module2 != null ? __create(__getProtoOf(module2)) : {}, "default", module2 && module2.__esModule && "default" in module2 ? { get: () => module2.default, enumerable: true } : { value: module2, enumerable: true })), module2);
|
|
24
|
+
};
|
|
25
|
+
__export(exports, {
|
|
26
|
+
useForceUpdate: () => useForceUpdate
|
|
27
|
+
});
|
|
28
|
+
var import_react = __toModule(require("react"));
|
|
29
|
+
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;
|
|
48
|
+
}
|
|
49
|
+
__name(useForceUpdate, "useForceUpdate");
|
|
50
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 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,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;",
|
|
6
|
+
"names": []
|
|
7
|
+
}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
var __defProp = Object.defineProperty;
|
|
2
|
+
var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
|
|
3
|
+
import { useEffect, useRef, useState } from "react";
|
|
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;
|
|
23
|
+
}
|
|
24
|
+
__name(useForceUpdate, "useForceUpdate");
|
|
25
|
+
export {
|
|
26
|
+
useForceUpdate
|
|
27
|
+
};
|
|
28
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 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;",
|
|
6
|
+
"names": []
|
|
7
|
+
}
|
package/dist/index.cjs
ADDED
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
var __create = Object.create;
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
6
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
7
|
+
var __markAsModule = (target) => __defProp(target, "__esModule", { value: true });
|
|
8
|
+
var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
|
|
9
|
+
var __export = (target, all) => {
|
|
10
|
+
__markAsModule(target);
|
|
11
|
+
for (var name in all)
|
|
12
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
13
|
+
};
|
|
14
|
+
var __reExport = (target, module2, desc) => {
|
|
15
|
+
if (module2 && typeof module2 === "object" || typeof module2 === "function") {
|
|
16
|
+
for (let key of __getOwnPropNames(module2))
|
|
17
|
+
if (!__hasOwnProp.call(target, key) && key !== "default")
|
|
18
|
+
__defProp(target, key, { get: () => module2[key], enumerable: !(desc = __getOwnPropDesc(module2, key)) || desc.enumerable });
|
|
19
|
+
}
|
|
20
|
+
return target;
|
|
21
|
+
};
|
|
22
|
+
var __toModule = (module2) => {
|
|
23
|
+
return __reExport(__markAsModule(__defProp(module2 != null ? __create(__getProtoOf(module2)) : {}, "default", module2 && module2.__esModule && "default" in module2 ? { get: () => module2.default, enumerable: true } : { value: module2, enumerable: true })), module2);
|
|
24
|
+
};
|
|
25
|
+
|
|
26
|
+
// src/index.ts
|
|
27
|
+
__export(exports, {
|
|
28
|
+
useForceUpdate: () => useForceUpdate
|
|
29
|
+
});
|
|
30
|
+
var import_react = __toModule(require("react"));
|
|
31
|
+
function useForceUpdate() {
|
|
32
|
+
const setState = (0, import_react.useState)(0)[1];
|
|
33
|
+
const internal = (0, import_react.useRef)();
|
|
34
|
+
if (!internal.current) {
|
|
35
|
+
internal.current = {
|
|
36
|
+
isMounted: true,
|
|
37
|
+
update: () => {
|
|
38
|
+
if (internal.current.isMounted) {
|
|
39
|
+
setState(Math.random());
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
};
|
|
43
|
+
}
|
|
44
|
+
(0, import_react.useEffect)(() => {
|
|
45
|
+
return () => {
|
|
46
|
+
internal.current.isMounted = false;
|
|
47
|
+
};
|
|
48
|
+
}, []);
|
|
49
|
+
return internal.current.update;
|
|
50
|
+
}
|
|
51
|
+
__name(useForceUpdate, "useForceUpdate");
|
|
52
|
+
//# sourceMappingURL=index.cjs.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 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,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;",
|
|
6
|
+
"names": []
|
|
7
|
+
}
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
var __defProp = Object.defineProperty;
|
|
2
|
+
var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
|
|
3
|
+
import { useEffect, useRef, useState } from "react";
|
|
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;
|
|
23
|
+
}
|
|
24
|
+
__name(useForceUpdate, "useForceUpdate");
|
|
25
|
+
export {
|
|
26
|
+
useForceUpdate
|
|
27
|
+
};
|
|
28
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 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;",
|
|
6
|
+
"names": []
|
|
7
|
+
}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
var __defProp = Object.defineProperty;
|
|
2
|
+
var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
|
|
3
|
+
import { useEffect, useRef, useState } from "react";
|
|
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;
|
|
23
|
+
}
|
|
24
|
+
__name(useForceUpdate, "useForceUpdate");
|
|
25
|
+
export {
|
|
26
|
+
useForceUpdate
|
|
27
|
+
};
|
package/package.json
ADDED
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@tamagui/use-force-update",
|
|
3
|
+
"version": "1.0.0-alpha.12",
|
|
4
|
+
"typings": "types",
|
|
5
|
+
"main": "dist/cjs",
|
|
6
|
+
"module": "dist/esm",
|
|
7
|
+
"module:jsx": "dist/_jsx",
|
|
8
|
+
"files": [
|
|
9
|
+
"types",
|
|
10
|
+
"src",
|
|
11
|
+
"dist"
|
|
12
|
+
],
|
|
13
|
+
"scripts": {
|
|
14
|
+
"build": "tamagui-build",
|
|
15
|
+
"watch": "tamagui-build --watch"
|
|
16
|
+
},
|
|
17
|
+
"devDependencies": {
|
|
18
|
+
"@tamagui/build": "^1.0.0-alpha.12"
|
|
19
|
+
},
|
|
20
|
+
"peerDependencies": {
|
|
21
|
+
"react": "*"
|
|
22
|
+
},
|
|
23
|
+
"publishConfig": {
|
|
24
|
+
"access": "public"
|
|
25
|
+
},
|
|
26
|
+
"gitHead": "d50261a4e08d2212395af4f2d8f49555fc780c3e"
|
|
27
|
+
}
|
package/src/index.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function useForceUpdate(): Function;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["index.ts"],"names":[],"mappings":"AAIA,wBAAgB,cAAc,aAqB7B"}
|
package/src/index.js
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { useEffect, useRef, useState } from 'react';
|
|
2
|
+
export function useForceUpdate() {
|
|
3
|
+
const setState = useState(0)[1];
|
|
4
|
+
const internal = useRef();
|
|
5
|
+
if (!internal.current) {
|
|
6
|
+
internal.current = {
|
|
7
|
+
isMounted: true,
|
|
8
|
+
update: () => {
|
|
9
|
+
if (internal.current.isMounted) {
|
|
10
|
+
setState(Math.random());
|
|
11
|
+
}
|
|
12
|
+
},
|
|
13
|
+
};
|
|
14
|
+
}
|
|
15
|
+
useEffect(() => {
|
|
16
|
+
return () => {
|
|
17
|
+
internal.current.isMounted = false;
|
|
18
|
+
};
|
|
19
|
+
}, []);
|
|
20
|
+
return internal.current.update;
|
|
21
|
+
}
|
package/src/index.ts
ADDED
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { useEffect, useRef, useState } from 'react'
|
|
2
|
+
|
|
3
|
+
// ensures no updates after unmount
|
|
4
|
+
|
|
5
|
+
export function useForceUpdate() {
|
|
6
|
+
const setState = useState(0)[1]
|
|
7
|
+
const internal = useRef<{ update: Function; isMounted: boolean }>()
|
|
8
|
+
if (!internal.current) {
|
|
9
|
+
internal.current = {
|
|
10
|
+
isMounted: true,
|
|
11
|
+
update: () => {
|
|
12
|
+
if (internal.current!.isMounted) {
|
|
13
|
+
setState(Math.random())
|
|
14
|
+
}
|
|
15
|
+
},
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
useEffect(() => {
|
|
20
|
+
return () => {
|
|
21
|
+
internal.current!.isMounted = false
|
|
22
|
+
}
|
|
23
|
+
}, [])
|
|
24
|
+
|
|
25
|
+
return internal.current.update
|
|
26
|
+
}
|
package/types/index.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAIA,wBAAgB,cAAc,aAqB7B"}
|