extra-react-hooks 0.1.13 → 0.1.14
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/README.md +13 -0
- package/dist/es2015/index.min.mjs +2 -2
- package/dist/es2015/index.min.mjs.map +1 -1
- package/dist/es2015/index.mjs +30 -1
- package/dist/es2015/index.mjs.map +1 -1
- package/dist/es2015/index.umd.js +31 -0
- package/dist/es2015/index.umd.js.map +1 -1
- package/dist/es2015/index.umd.min.js +2 -2
- package/dist/es2015/index.umd.min.js.map +1 -1
- package/dist/es2018/index.min.mjs +2 -2
- package/dist/es2018/index.min.mjs.map +1 -1
- package/dist/es2018/index.mjs +30 -1
- package/dist/es2018/index.mjs.map +1 -1
- package/dist/es2018/index.umd.js +31 -0
- package/dist/es2018/index.umd.js.map +1 -1
- package/dist/es2018/index.umd.min.js +2 -2
- package/dist/es2018/index.umd.min.js.map +1 -1
- package/lib/es2015/index.d.ts +2 -0
- package/lib/es2015/index.js +2 -0
- package/lib/es2015/index.js.map +1 -1
- package/lib/es2015/use-is-first-render.d.ts +1 -0
- package/lib/es2015/use-is-first-render.js +25 -0
- package/lib/es2015/use-is-first-render.js.map +1 -0
- package/lib/es2015/use-update-effect.d.ts +2 -0
- package/lib/es2015/use-update-effect.js +15 -0
- package/lib/es2015/use-update-effect.js.map +1 -0
- package/lib/es2018/index.d.ts +2 -0
- package/lib/es2018/index.js +2 -0
- package/lib/es2018/index.js.map +1 -1
- package/lib/es2018/use-is-first-render.d.ts +1 -0
- package/lib/es2018/use-is-first-render.js +25 -0
- package/lib/es2018/use-is-first-render.js.map +1 -0
- package/lib/es2018/use-update-effect.d.ts +2 -0
- package/lib/es2018/use-update-effect.js +15 -0
- package/lib/es2018/use-update-effect.js.map +1 -0
- package/package.json +1 -1
package/lib/es2015/index.d.ts
CHANGED
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
export * from './use-increment';
|
|
2
2
|
export * from './use-is-mounted';
|
|
3
|
+
export * from './use-is-first-render';
|
|
3
4
|
export * from './use-mount';
|
|
5
|
+
export * from './use-update-effect';
|
|
4
6
|
export * from './use-single-selection';
|
|
5
7
|
export * from './use-multiple-selection';
|
|
6
8
|
export * from './use-state-cycle';
|
package/lib/es2015/index.js
CHANGED
|
@@ -16,7 +16,9 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
|
16
16
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
17
|
__exportStar(require("./use-increment"), exports);
|
|
18
18
|
__exportStar(require("./use-is-mounted"), exports);
|
|
19
|
+
__exportStar(require("./use-is-first-render"), exports);
|
|
19
20
|
__exportStar(require("./use-mount"), exports);
|
|
21
|
+
__exportStar(require("./use-update-effect"), exports);
|
|
20
22
|
__exportStar(require("./use-single-selection"), exports);
|
|
21
23
|
__exportStar(require("./use-multiple-selection"), exports);
|
|
22
24
|
__exportStar(require("./use-state-cycle"), exports);
|
package/lib/es2015/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,kDAA+B;AAC/B,mDAAgC;AAChC,8CAA2B;AAC3B,yDAAsC;AACtC,2DAAwC;AACxC,oDAAiC;AACjC,+CAA4B;AAC5B,wDAAqC;AACrC,6CAA0B;AAC1B,qDAAkC;AAClC,6DAA0C"}
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,kDAA+B;AAC/B,mDAAgC;AAChC,wDAAqC;AACrC,8CAA2B;AAC3B,sDAAmC;AACnC,yDAAsC;AACtC,2DAAwC;AACxC,oDAAiC;AACjC,+CAA4B;AAC5B,wDAAqC;AACrC,6CAA0B;AAC1B,qDAAkC;AAClC,6DAA0C"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function useIsFirstRender(): () => boolean;
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.useIsFirstRender = void 0;
|
|
4
|
+
const react_1 = require("react");
|
|
5
|
+
var State;
|
|
6
|
+
(function (State) {
|
|
7
|
+
State[State["InitialValue"] = 0] = "InitialValue";
|
|
8
|
+
State[State["First"] = 1] = "First";
|
|
9
|
+
State[State["NotFirst"] = 2] = "NotFirst";
|
|
10
|
+
})(State || (State = {}));
|
|
11
|
+
function useIsFirstRender() {
|
|
12
|
+
const state = (0, react_1.useRef)(State.InitialValue);
|
|
13
|
+
switch (state.current) {
|
|
14
|
+
case State.InitialValue:
|
|
15
|
+
state.current = State.First;
|
|
16
|
+
break;
|
|
17
|
+
case State.First:
|
|
18
|
+
state.current = State.NotFirst;
|
|
19
|
+
break;
|
|
20
|
+
case State.NotFirst: break;
|
|
21
|
+
}
|
|
22
|
+
return () => state.current === State.First;
|
|
23
|
+
}
|
|
24
|
+
exports.useIsFirstRender = useIsFirstRender;
|
|
25
|
+
//# sourceMappingURL=use-is-first-render.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"use-is-first-render.js","sourceRoot":"","sources":["../../src/use-is-first-render.ts"],"names":[],"mappings":";;;AAAA,iCAA8B;AAE9B,IAAK,KAIJ;AAJD,WAAK,KAAK;IACR,iDAAY,CAAA;IACZ,mCAAK,CAAA;IACL,yCAAQ,CAAA;AACV,CAAC,EAJI,KAAK,KAAL,KAAK,QAIT;AAED,SAAgB,gBAAgB;IAC9B,MAAM,KAAK,GAAG,IAAA,cAAM,EAAC,KAAK,CAAC,YAAY,CAAC,CAAA;IAExC,QAAQ,KAAK,CAAC,OAAO,EAAE;QACrB,KAAK,KAAK,CAAC,YAAY;YACrB,KAAK,CAAC,OAAO,GAAG,KAAK,CAAC,KAAK,CAAA;YAC3B,MAAK;QACP,KAAK,KAAK,CAAC,KAAK;YACd,KAAK,CAAC,OAAO,GAAG,KAAK,CAAC,QAAQ,CAAA;YAC9B,MAAK;QACP,KAAK,KAAK,CAAC,QAAQ,CAAC,CAAC,MAAK;KAC3B;IAED,OAAO,GAAG,EAAE,CAAC,KAAK,CAAC,OAAO,KAAK,KAAK,CAAC,KAAK,CAAA;AAC5C,CAAC;AAdD,4CAcC"}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.useUpdateEffect = void 0;
|
|
4
|
+
const react_1 = require("react");
|
|
5
|
+
const use_is_first_render_1 = require("./use-is-first-render");
|
|
6
|
+
function useUpdateEffect(effect, deps) {
|
|
7
|
+
const isFirstRender = (0, use_is_first_render_1.useIsFirstRender)();
|
|
8
|
+
(0, react_1.useEffect)(() => {
|
|
9
|
+
if (!isFirstRender()) {
|
|
10
|
+
return effect();
|
|
11
|
+
}
|
|
12
|
+
}, deps);
|
|
13
|
+
}
|
|
14
|
+
exports.useUpdateEffect = useUpdateEffect;
|
|
15
|
+
//# sourceMappingURL=use-update-effect.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"use-update-effect.js","sourceRoot":"","sources":["../../src/use-update-effect.ts"],"names":[],"mappings":";;;AAAA,iCAAiD;AACjD,+DAAwD;AAExD,SAAgB,eAAe,CAC7B,MAAsB,EACtB,IAA2B;IAE3B,MAAM,aAAa,GAAG,IAAA,sCAAgB,GAAE,CAAA;IAExC,IAAA,iBAAS,EAAC,GAAG,EAAE;QACb,IAAI,CAAC,aAAa,EAAE,EAAE;YACpB,OAAO,MAAM,EAAE,CAAA;SAChB;IACH,CAAC,EAAE,IAAI,CAAC,CAAA;AACV,CAAC;AAXD,0CAWC"}
|
package/lib/es2018/index.d.ts
CHANGED
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
export * from './use-increment';
|
|
2
2
|
export * from './use-is-mounted';
|
|
3
|
+
export * from './use-is-first-render';
|
|
3
4
|
export * from './use-mount';
|
|
5
|
+
export * from './use-update-effect';
|
|
4
6
|
export * from './use-single-selection';
|
|
5
7
|
export * from './use-multiple-selection';
|
|
6
8
|
export * from './use-state-cycle';
|
package/lib/es2018/index.js
CHANGED
|
@@ -16,7 +16,9 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
|
16
16
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
17
|
__exportStar(require("./use-increment"), exports);
|
|
18
18
|
__exportStar(require("./use-is-mounted"), exports);
|
|
19
|
+
__exportStar(require("./use-is-first-render"), exports);
|
|
19
20
|
__exportStar(require("./use-mount"), exports);
|
|
21
|
+
__exportStar(require("./use-update-effect"), exports);
|
|
20
22
|
__exportStar(require("./use-single-selection"), exports);
|
|
21
23
|
__exportStar(require("./use-multiple-selection"), exports);
|
|
22
24
|
__exportStar(require("./use-state-cycle"), exports);
|
package/lib/es2018/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,kDAA+B;AAC/B,mDAAgC;AAChC,8CAA2B;AAC3B,yDAAsC;AACtC,2DAAwC;AACxC,oDAAiC;AACjC,+CAA4B;AAC5B,wDAAqC;AACrC,6CAA0B;AAC1B,qDAAkC;AAClC,6DAA0C"}
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,kDAA+B;AAC/B,mDAAgC;AAChC,wDAAqC;AACrC,8CAA2B;AAC3B,sDAAmC;AACnC,yDAAsC;AACtC,2DAAwC;AACxC,oDAAiC;AACjC,+CAA4B;AAC5B,wDAAqC;AACrC,6CAA0B;AAC1B,qDAAkC;AAClC,6DAA0C"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function useIsFirstRender(): () => boolean;
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.useIsFirstRender = void 0;
|
|
4
|
+
const react_1 = require("react");
|
|
5
|
+
var State;
|
|
6
|
+
(function (State) {
|
|
7
|
+
State[State["InitialValue"] = 0] = "InitialValue";
|
|
8
|
+
State[State["First"] = 1] = "First";
|
|
9
|
+
State[State["NotFirst"] = 2] = "NotFirst";
|
|
10
|
+
})(State || (State = {}));
|
|
11
|
+
function useIsFirstRender() {
|
|
12
|
+
const state = (0, react_1.useRef)(State.InitialValue);
|
|
13
|
+
switch (state.current) {
|
|
14
|
+
case State.InitialValue:
|
|
15
|
+
state.current = State.First;
|
|
16
|
+
break;
|
|
17
|
+
case State.First:
|
|
18
|
+
state.current = State.NotFirst;
|
|
19
|
+
break;
|
|
20
|
+
case State.NotFirst: break;
|
|
21
|
+
}
|
|
22
|
+
return () => state.current === State.First;
|
|
23
|
+
}
|
|
24
|
+
exports.useIsFirstRender = useIsFirstRender;
|
|
25
|
+
//# sourceMappingURL=use-is-first-render.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"use-is-first-render.js","sourceRoot":"","sources":["../../src/use-is-first-render.ts"],"names":[],"mappings":";;;AAAA,iCAA8B;AAE9B,IAAK,KAIJ;AAJD,WAAK,KAAK;IACR,iDAAY,CAAA;IACZ,mCAAK,CAAA;IACL,yCAAQ,CAAA;AACV,CAAC,EAJI,KAAK,KAAL,KAAK,QAIT;AAED,SAAgB,gBAAgB;IAC9B,MAAM,KAAK,GAAG,IAAA,cAAM,EAAC,KAAK,CAAC,YAAY,CAAC,CAAA;IAExC,QAAQ,KAAK,CAAC,OAAO,EAAE;QACrB,KAAK,KAAK,CAAC,YAAY;YACrB,KAAK,CAAC,OAAO,GAAG,KAAK,CAAC,KAAK,CAAA;YAC3B,MAAK;QACP,KAAK,KAAK,CAAC,KAAK;YACd,KAAK,CAAC,OAAO,GAAG,KAAK,CAAC,QAAQ,CAAA;YAC9B,MAAK;QACP,KAAK,KAAK,CAAC,QAAQ,CAAC,CAAC,MAAK;KAC3B;IAED,OAAO,GAAG,EAAE,CAAC,KAAK,CAAC,OAAO,KAAK,KAAK,CAAC,KAAK,CAAA;AAC5C,CAAC;AAdD,4CAcC"}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.useUpdateEffect = void 0;
|
|
4
|
+
const react_1 = require("react");
|
|
5
|
+
const use_is_first_render_1 = require("./use-is-first-render");
|
|
6
|
+
function useUpdateEffect(effect, deps) {
|
|
7
|
+
const isFirstRender = (0, use_is_first_render_1.useIsFirstRender)();
|
|
8
|
+
(0, react_1.useEffect)(() => {
|
|
9
|
+
if (!isFirstRender()) {
|
|
10
|
+
return effect();
|
|
11
|
+
}
|
|
12
|
+
}, deps);
|
|
13
|
+
}
|
|
14
|
+
exports.useUpdateEffect = useUpdateEffect;
|
|
15
|
+
//# sourceMappingURL=use-update-effect.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"use-update-effect.js","sourceRoot":"","sources":["../../src/use-update-effect.ts"],"names":[],"mappings":";;;AAAA,iCAAiD;AACjD,+DAAwD;AAExD,SAAgB,eAAe,CAC7B,MAAsB,EACtB,IAA2B;IAE3B,MAAM,aAAa,GAAG,IAAA,sCAAgB,GAAE,CAAA;IAExC,IAAA,iBAAS,EAAC,GAAG,EAAE;QACb,IAAI,CAAC,aAAa,EAAE,EAAE;YACpB,OAAO,MAAM,EAAE,CAAA;SAChB;IACH,CAAC,EAAE,IAAI,CAAC,CAAA;AACV,CAAC;AAXD,0CAWC"}
|