@tamagui/use-previous 2.0.0-rc.4 → 2.0.0-rc.40
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.cjs +31 -23
- package/dist/cjs/index.native.js +29 -23
- package/dist/cjs/index.native.js.map +1 -1
- package/dist/esm/index.js +12 -5
- package/dist/esm/index.js.map +1 -6
- package/dist/esm/index.mjs +7 -1
- package/dist/esm/index.mjs.map +1 -1
- package/dist/esm/index.native.js +5 -1
- package/dist/esm/index.native.js.map +1 -1
- package/package.json +5 -8
- package/types/index.d.ts.map +2 -2
- package/dist/cjs/index.js +0 -33
- package/dist/cjs/index.js.map +0 -6
package/dist/cjs/index.cjs
CHANGED
|
@@ -2,33 +2,35 @@ var __create = Object.create;
|
|
|
2
2
|
var __defProp = Object.defineProperty;
|
|
3
3
|
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
4
|
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
-
var __getProtoOf = Object.getPrototypeOf
|
|
6
|
-
|
|
5
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
6
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
7
7
|
var __export = (target, all) => {
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
8
|
+
for (var name in all) __defProp(target, name, {
|
|
9
|
+
get: all[name],
|
|
10
|
+
enumerable: true
|
|
11
|
+
});
|
|
12
|
+
};
|
|
13
|
+
var __copyProps = (to, from, except, desc) => {
|
|
14
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
15
|
+
for (let key of __getOwnPropNames(from)) if (!__hasOwnProp.call(to, key) && key !== except) __defProp(to, key, {
|
|
15
16
|
get: () => from[key],
|
|
16
17
|
enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
|
|
17
18
|
});
|
|
18
|
-
|
|
19
|
-
|
|
19
|
+
}
|
|
20
|
+
return to;
|
|
21
|
+
};
|
|
20
22
|
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
23
|
+
// If the importer is in node compatibility mode or this is not an ESM
|
|
24
|
+
// file that has been converted to a CommonJS file using a Babel-
|
|
25
|
+
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
26
|
+
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
27
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", {
|
|
28
|
+
value: mod,
|
|
29
|
+
enumerable: true
|
|
30
|
+
}) : target, mod));
|
|
31
|
+
var __toCommonJS = mod => __copyProps(__defProp({}, "__esModule", {
|
|
32
|
+
value: true
|
|
33
|
+
}), mod);
|
|
32
34
|
var index_exports = {};
|
|
33
35
|
__export(index_exports, {
|
|
34
36
|
usePrevious: () => usePrevious
|
|
@@ -40,5 +42,11 @@ function usePrevious(value) {
|
|
|
40
42
|
value,
|
|
41
43
|
previous: value
|
|
42
44
|
});
|
|
43
|
-
return React.useMemo(() =>
|
|
45
|
+
return React.useMemo(() => {
|
|
46
|
+
if (ref.current.value !== value) {
|
|
47
|
+
ref.current.previous = ref.current.value;
|
|
48
|
+
ref.current.value = value;
|
|
49
|
+
}
|
|
50
|
+
return ref.current.previous;
|
|
51
|
+
}, [value]);
|
|
44
52
|
}
|
package/dist/cjs/index.native.js
CHANGED
|
@@ -4,33 +4,35 @@ var __create = Object.create;
|
|
|
4
4
|
var __defProp = Object.defineProperty;
|
|
5
5
|
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
6
6
|
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
7
|
-
var __getProtoOf = Object.getPrototypeOf
|
|
8
|
-
|
|
7
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
8
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
9
9
|
var __export = (target, all) => {
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
10
|
+
for (var name in all) __defProp(target, name, {
|
|
11
|
+
get: all[name],
|
|
12
|
+
enumerable: true
|
|
13
|
+
});
|
|
14
|
+
};
|
|
15
|
+
var __copyProps = (to, from, except, desc) => {
|
|
16
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
17
|
+
for (let key of __getOwnPropNames(from)) if (!__hasOwnProp.call(to, key) && key !== except) __defProp(to, key, {
|
|
17
18
|
get: () => from[key],
|
|
18
19
|
enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
|
|
19
20
|
});
|
|
20
|
-
|
|
21
|
-
|
|
21
|
+
}
|
|
22
|
+
return to;
|
|
23
|
+
};
|
|
22
24
|
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
25
|
+
// If the importer is in node compatibility mode or this is not an ESM
|
|
26
|
+
// file that has been converted to a CommonJS file using a Babel-
|
|
27
|
+
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
28
|
+
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
29
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", {
|
|
30
|
+
value: mod,
|
|
31
|
+
enumerable: true
|
|
32
|
+
}) : target, mod));
|
|
33
|
+
var __toCommonJS = mod => __copyProps(__defProp({}, "__esModule", {
|
|
34
|
+
value: true
|
|
35
|
+
}), mod);
|
|
34
36
|
var index_exports = {};
|
|
35
37
|
__export(index_exports, {
|
|
36
38
|
usePrevious: () => usePrevious
|
|
@@ -43,7 +45,11 @@ function usePrevious(value) {
|
|
|
43
45
|
previous: value
|
|
44
46
|
});
|
|
45
47
|
return React.useMemo(function () {
|
|
46
|
-
|
|
48
|
+
if (ref.current.value !== value) {
|
|
49
|
+
ref.current.previous = ref.current.value;
|
|
50
|
+
ref.current.value = value;
|
|
51
|
+
}
|
|
52
|
+
return ref.current.previous;
|
|
47
53
|
}, [value]);
|
|
48
54
|
}
|
|
49
55
|
//# sourceMappingURL=index.native.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["__toCommonJS","mod","__copyProps","__defProp","value","index_exports","__export","usePrevious","module","exports","React","__toESM","require","ref","useRef"],"sources":["../../src/index.ts"],"sourcesContent":[null],"mappings":"
|
|
1
|
+
{"version":3,"names":["__toCommonJS","mod","__copyProps","__defProp","value","index_exports","__export","usePrevious","module","exports","React","__toESM","require","ref","useRef","previous","useMemo","current"],"sources":["../../src/index.ts"],"sourcesContent":[null],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,IAAAA,YAAA,GAAAC,GAAA,IAAAC,WAAA,CAAAC,SAAA;EAAAC,KAAA;AAAA,IAAAH,GAAA;AAAA,IAAAI,aAAA;AAAAC,QAAA,CAAAD,aAAA;EAAAE,WAAA,EAAAA,CAAA,KAAAA;AAAA;AAEAC,MAAA,CAAAC,OAAuB,GAAAT,YAAA,CAAAK,aAAA;AAEhB,IAAAK,KAAS,GAAAC,OAAA,CAAAC,OAAe,CAAa;AAC1C,SAAML,WAAYA,CAAAH,KAAA,EAAO;EAKzB,IAAAS,GAAO,GAAAH,KAAM,CAAAI,MAAQ;IACnBV,KAAI;IACFW,QAAI,EAAAX;EACJ;EAAoB,OACtBM,KAAA,CAAAM,OAAA;IACA,IAAAH,GAAO,CAAAI,OAAI,CAAAb,KAAQ,KAAAA,KAAA;MACjBS,GAAA,CAAAI,OAAM,CAAAF,QAAA,GAAAF,GAAA,CAAAI,OAAA,CAAAb,KAAA;MACZS,GAAA,CAAAI,OAAA,CAAAb,KAAA,GAAAA,KAAA","ignoreList":[]}
|
package/dist/esm/index.js
CHANGED
|
@@ -1,9 +1,16 @@
|
|
|
1
1
|
import * as React from "react";
|
|
2
2
|
function usePrevious(value) {
|
|
3
|
-
const ref = React.useRef({
|
|
4
|
-
|
|
3
|
+
const ref = React.useRef({
|
|
4
|
+
value,
|
|
5
|
+
previous: value
|
|
6
|
+
});
|
|
7
|
+
return React.useMemo(() => {
|
|
8
|
+
if (ref.current.value !== value) {
|
|
9
|
+
ref.current.previous = ref.current.value;
|
|
10
|
+
ref.current.value = value;
|
|
11
|
+
}
|
|
12
|
+
return ref.current.previous;
|
|
13
|
+
}, [value]);
|
|
5
14
|
}
|
|
6
|
-
export {
|
|
7
|
-
usePrevious
|
|
8
|
-
};
|
|
15
|
+
export { usePrevious };
|
|
9
16
|
//# sourceMappingURL=index.js.map
|
package/dist/esm/index.js.map
CHANGED
|
@@ -1,6 +1 @@
|
|
|
1
|
-
{
|
|
2
|
-
"version": 3,
|
|
3
|
-
"sources": ["../../src/index.ts"],
|
|
4
|
-
"mappings": "AAEA,YAAY,WAAW;AAEhB,SAAS,YAAe,OAAa;AAC1C,QAAM,MAAM,MAAM,OAAO,EAAE,OAAO,UAAU,MAAM,CAAC;AAKnD,SAAO,MAAM,QAAQ,OACf,IAAI,QAAQ,UAAU,UACxB,IAAI,QAAQ,WAAW,IAAI,QAAQ,OACnC,IAAI,QAAQ,QAAQ,QAEf,IAAI,QAAQ,WAClB,CAAC,KAAK,CAAC;AACZ;",
|
|
5
|
-
"names": []
|
|
6
|
-
}
|
|
1
|
+
{"version":3,"names":["React","usePrevious","value","ref","useRef","previous","useMemo","current"],"sources":["../../src/index.ts"],"sourcesContent":[null],"mappings":"AAEA,YAAYA,KAAA,MAAW;AAEhB,SAASC,YAAeC,KAAA,EAAa;EAC1C,MAAMC,GAAA,GAAMH,KAAA,CAAMI,MAAA,CAAO;IAAEF,KAAA;IAAOG,QAAA,EAAUH;EAAM,CAAC;EAKnD,OAAOF,KAAA,CAAMM,OAAA,CAAQ,MAAM;IACzB,IAAIH,GAAA,CAAII,OAAA,CAAQL,KAAA,KAAUA,KAAA,EAAO;MAC/BC,GAAA,CAAII,OAAA,CAAQF,QAAA,GAAWF,GAAA,CAAII,OAAA,CAAQL,KAAA;MACnCC,GAAA,CAAII,OAAA,CAAQL,KAAA,GAAQA,KAAA;IACtB;IACA,OAAOC,GAAA,CAAII,OAAA,CAAQF,QAAA;EACrB,GAAG,CAACH,KAAK,CAAC;AACZ","ignoreList":[]}
|
package/dist/esm/index.mjs
CHANGED
|
@@ -4,7 +4,13 @@ function usePrevious(value) {
|
|
|
4
4
|
value,
|
|
5
5
|
previous: value
|
|
6
6
|
});
|
|
7
|
-
return React.useMemo(() =>
|
|
7
|
+
return React.useMemo(() => {
|
|
8
|
+
if (ref.current.value !== value) {
|
|
9
|
+
ref.current.previous = ref.current.value;
|
|
10
|
+
ref.current.value = value;
|
|
11
|
+
}
|
|
12
|
+
return ref.current.previous;
|
|
13
|
+
}, [value]);
|
|
8
14
|
}
|
|
9
15
|
export { usePrevious };
|
|
10
16
|
//# sourceMappingURL=index.mjs.map
|
package/dist/esm/index.mjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["React","usePrevious","value","ref","useRef","previous","useMemo","current"],"sources":["../../src/index.ts"],"sourcesContent":[null],"mappings":"AAEA,YAAYA,KAAA,MAAW;AAEhB,SAASC,YAAeC,KAAA,EAAa;EAC1C,MAAMC,GAAA,GAAMH,KAAA,CAAMI,MAAA,CAAO;IAAEF,KAAA;IAAOG,QAAA,EAAUH;EAAM,CAAC;EAKnD,OAAOF,KAAA,CAAMM,OAAA,CAAQ,
|
|
1
|
+
{"version":3,"names":["React","usePrevious","value","ref","useRef","previous","useMemo","current"],"sources":["../../src/index.ts"],"sourcesContent":[null],"mappings":"AAEA,YAAYA,KAAA,MAAW;AAEhB,SAASC,YAAeC,KAAA,EAAa;EAC1C,MAAMC,GAAA,GAAMH,KAAA,CAAMI,MAAA,CAAO;IAAEF,KAAA;IAAOG,QAAA,EAAUH;EAAM,CAAC;EAKnD,OAAOF,KAAA,CAAMM,OAAA,CAAQ,MAAM;IACzB,IAAIH,GAAA,CAAII,OAAA,CAAQL,KAAA,KAAUA,KAAA,EAAO;MAC/BC,GAAA,CAAII,OAAA,CAAQF,QAAA,GAAWF,GAAA,CAAII,OAAA,CAAQL,KAAA;MACnCC,GAAA,CAAII,OAAA,CAAQL,KAAA,GAAQA,KAAA;IACtB;IACA,OAAOC,GAAA,CAAII,OAAA,CAAQF,QAAA;EACrB,GAAG,CAACH,KAAK,CAAC;AACZ","ignoreList":[]}
|
package/dist/esm/index.native.js
CHANGED
|
@@ -5,7 +5,11 @@ function usePrevious(value) {
|
|
|
5
5
|
previous: value
|
|
6
6
|
});
|
|
7
7
|
return React.useMemo(function () {
|
|
8
|
-
|
|
8
|
+
if (ref.current.value !== value) {
|
|
9
|
+
ref.current.previous = ref.current.value;
|
|
10
|
+
ref.current.value = value;
|
|
11
|
+
}
|
|
12
|
+
return ref.current.previous;
|
|
9
13
|
}, [value]);
|
|
10
14
|
}
|
|
11
15
|
export { usePrevious };
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["React","usePrevious","value","ref","useRef","previous"],"sources":["../../src/index.ts"],"sourcesContent":[null],"mappings":"AAEA,YAAYA,KAAA,MAAW;AAEhB,SAASC,YAAeC,KAAA,EAAa;EAC1C,IAAAC,GAAM,GAAAH,KAAM,CAAAI,MAAM;IAKlBF,KAAO;
|
|
1
|
+
{"version":3,"names":["React","usePrevious","value","ref","useRef","previous","useMemo","current"],"sources":["../../src/index.ts"],"sourcesContent":[null],"mappings":"AAEA,YAAYA,KAAA,MAAW;AAEhB,SAASC,YAAeC,KAAA,EAAa;EAC1C,IAAAC,GAAM,GAAAH,KAAM,CAAAI,MAAM;IAKlBF,KAAO;IACLG,QAAQ,EAAAH;EACN;EACA,OAAAF,KAAI,CAAAM,OAAQ,aAAQ;IACtB,IAAAH,GAAA,CAAAI,OAAA,CAAAL,KAAA,KAAAA,KAAA;MACAC,GAAA,CAAAI,OAAW,CAAAF,QAAQ,GAAAF,GAAA,CAAAI,OAAA,CAAAL,KAAA;MACjBC,GAAA,CAAAI,OAAM,CAAAL,KAAA,GAAAA,KAAA;IACZ","ignoreList":[]}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@tamagui/use-previous",
|
|
3
|
-
"version": "2.0.0-rc.
|
|
3
|
+
"version": "2.0.0-rc.40",
|
|
4
4
|
"files": [
|
|
5
5
|
"src",
|
|
6
6
|
"types",
|
|
@@ -15,15 +15,12 @@
|
|
|
15
15
|
"./package.json": "./package.json",
|
|
16
16
|
".": {
|
|
17
17
|
"types": "./types/index.d.ts",
|
|
18
|
-
"react-native":
|
|
19
|
-
|
|
20
|
-
"import": "./dist/esm/index.native.js",
|
|
21
|
-
"require": "./dist/cjs/index.native.js"
|
|
22
|
-
},
|
|
18
|
+
"react-native": "./dist/esm/index.native.js",
|
|
19
|
+
"browser": "./dist/esm/index.mjs",
|
|
23
20
|
"module": "./dist/esm/index.mjs",
|
|
24
21
|
"import": "./dist/esm/index.mjs",
|
|
25
22
|
"require": "./dist/cjs/index.cjs",
|
|
26
|
-
"default": "./dist/
|
|
23
|
+
"default": "./dist/esm/index.mjs"
|
|
27
24
|
}
|
|
28
25
|
},
|
|
29
26
|
"publishConfig": {
|
|
@@ -36,7 +33,7 @@
|
|
|
36
33
|
"clean:build": "tamagui-build clean:build"
|
|
37
34
|
},
|
|
38
35
|
"devDependencies": {
|
|
39
|
-
"@tamagui/build": "2.0.0-rc.
|
|
36
|
+
"@tamagui/build": "2.0.0-rc.40",
|
|
40
37
|
"react": ">=19"
|
|
41
38
|
},
|
|
42
39
|
"peerDependencies": {
|
package/types/index.d.ts.map
CHANGED
|
@@ -4,8 +4,8 @@
|
|
|
4
4
|
"sources": [
|
|
5
5
|
"src/index.ts"
|
|
6
6
|
],
|
|
7
|
+
"version": 3,
|
|
7
8
|
"sourcesContent": [
|
|
8
9
|
"// via radix-ui\n\nimport * as React from 'react'\n\nexport function usePrevious<T>(value: T): T {\n const ref = React.useRef({ value, previous: value })\n\n // We compare values before making an update to ensure that\n // a change has been made. This ensures the previous value is\n // persisted correctly between renders.\n return React.useMemo(() => {\n if (ref.current.value !== value) {\n ref.current.previous = ref.current.value\n ref.current.value = value\n }\n return ref.current.previous\n }, [value])\n}\n"
|
|
9
|
-
]
|
|
10
|
-
"version": 3
|
|
10
|
+
]
|
|
11
11
|
}
|
package/dist/cjs/index.js
DELETED
|
@@ -1,33 +0,0 @@
|
|
|
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, __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
-
var __export = (target, all) => {
|
|
7
|
-
for (var name in all)
|
|
8
|
-
__defProp(target, name, { get: all[name], enumerable: !0 });
|
|
9
|
-
}, __copyProps = (to, from, except, desc) => {
|
|
10
|
-
if (from && typeof from == "object" || typeof from == "function")
|
|
11
|
-
for (let key of __getOwnPropNames(from))
|
|
12
|
-
!__hasOwnProp.call(to, key) && key !== except && __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
13
|
-
return to;
|
|
14
|
-
};
|
|
15
|
-
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
16
|
-
// If the importer is in node compatibility mode or this is not an ESM
|
|
17
|
-
// file that has been converted to a CommonJS file using a Babel-
|
|
18
|
-
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
19
|
-
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
20
|
-
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: !0 }) : target,
|
|
21
|
-
mod
|
|
22
|
-
)), __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: !0 }), mod);
|
|
23
|
-
var index_exports = {};
|
|
24
|
-
__export(index_exports, {
|
|
25
|
-
usePrevious: () => usePrevious
|
|
26
|
-
});
|
|
27
|
-
module.exports = __toCommonJS(index_exports);
|
|
28
|
-
var React = __toESM(require("react"), 1);
|
|
29
|
-
function usePrevious(value) {
|
|
30
|
-
const ref = React.useRef({ value, previous: value });
|
|
31
|
-
return React.useMemo(() => (ref.current.value !== value && (ref.current.previous = ref.current.value, ref.current.value = value), ref.current.previous), [value]);
|
|
32
|
-
}
|
|
33
|
-
//# sourceMappingURL=index.js.map
|
package/dist/cjs/index.js.map
DELETED
|
@@ -1,6 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"version": 3,
|
|
3
|
-
"sources": ["../../src/index.ts"],
|
|
4
|
-
"mappings": ";;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAEA,YAAuB;AAEhB,SAAS,YAAe,OAAa;AAC1C,QAAM,MAAM,MAAM,OAAO,EAAE,OAAO,UAAU,MAAM,CAAC;AAKnD,SAAO,MAAM,QAAQ,OACf,IAAI,QAAQ,UAAU,UACxB,IAAI,QAAQ,WAAW,IAAI,QAAQ,OACnC,IAAI,QAAQ,QAAQ,QAEf,IAAI,QAAQ,WAClB,CAAC,KAAK,CAAC;AACZ;",
|
|
5
|
-
"names": []
|
|
6
|
-
}
|