@react-hookz/web
Advanced tools
Comparing version 1.9.1 to 1.10.0
@@ -0,1 +1,8 @@ | ||
# [1.10.0](https://github.com/react-hookz/web/compare/v1.9.1...v1.10.0) (2021-04-28) | ||
### Features | ||
* new hooks, useConditionalEffect and useConditionalUpdateEffect ([#26](https://github.com/react-hookz/web/issues/26)) ([eb7f0a5](https://github.com/react-hookz/web/commit/eb7f0a525d00e9b66955177599a4a77ae1647867)) | ||
## [1.9.1](https://github.com/react-hookz/web/compare/v1.9.0...v1.9.1) (2021-04-28) | ||
@@ -2,0 +9,0 @@ |
@@ -9,1 +9,3 @@ export { useFirstMountState } from './useFirstMountState'; | ||
export { useIsMounted } from './useIsMounted'; | ||
export { useConditionalEffect } from './useConditionalEffect'; | ||
export { useConditionalUpdateEffect } from './useConditionalUpdateEffect'; |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.useIsMounted = exports.usePrevious = exports.useRerender = exports.useToggle = exports.useUnmountEffect = exports.useUpdateEffect = exports.useMountEffect = exports.useFirstMountState = void 0; | ||
exports.useConditionalUpdateEffect = exports.useConditionalEffect = exports.useIsMounted = exports.usePrevious = exports.useRerender = exports.useToggle = exports.useUnmountEffect = exports.useUpdateEffect = exports.useMountEffect = exports.useFirstMountState = void 0; | ||
var useFirstMountState_1 = require("./useFirstMountState"); | ||
@@ -20,1 +20,5 @@ Object.defineProperty(exports, "useFirstMountState", { enumerable: true, get: function () { return useFirstMountState_1.useFirstMountState; } }); | ||
Object.defineProperty(exports, "useIsMounted", { enumerable: true, get: function () { return useIsMounted_1.useIsMounted; } }); | ||
var useConditionalEffect_1 = require("./useConditionalEffect"); | ||
Object.defineProperty(exports, "useConditionalEffect", { enumerable: true, get: function () { return useConditionalEffect_1.useConditionalEffect; } }); | ||
var useConditionalUpdateEffect_1 = require("./useConditionalUpdateEffect"); | ||
Object.defineProperty(exports, "useConditionalUpdateEffect", { enumerable: true, get: function () { return useConditionalUpdateEffect_1.useConditionalUpdateEffect; } }); |
@@ -6,2 +6,3 @@ "use strict"; | ||
var useFirstMountState_1 = require("./useFirstMountState"); | ||
var const_1 = require("./util/const"); | ||
/** | ||
@@ -15,10 +16,5 @@ * Effect hook that ignores the first render (not invoked on mount). | ||
var isFirstMount = useFirstMountState_1.useFirstMountState(); | ||
// eslint-disable-next-line consistent-return | ||
react_1.useEffect(function () { | ||
if (!isFirstMount) { | ||
return effect(); | ||
} | ||
// eslint-disable-next-line react-hooks/exhaustive-deps | ||
}, deps); | ||
// eslint-disable-next-line react-hooks/exhaustive-deps | ||
react_1.useEffect(isFirstMount ? const_1.noop : effect, deps); | ||
} | ||
exports.useUpdateEffect = useUpdateEffect; |
export declare const noop: () => void; | ||
export declare const isBrowser: boolean; | ||
export declare function truthyArrayItemsPredicate(conditions: ReadonlyArray<any>): boolean; |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.isBrowser = exports.noop = void 0; | ||
exports.truthyArrayItemsPredicate = exports.isBrowser = exports.noop = void 0; | ||
var noop = function () { }; | ||
@@ -9,1 +9,6 @@ exports.noop = noop; | ||
typeof document !== 'undefined'; | ||
// eslint-disable-next-line @typescript-eslint/no-explicit-any | ||
function truthyArrayItemsPredicate(conditions) { | ||
return conditions.every(function (i) { return Boolean(i); }); | ||
} | ||
exports.truthyArrayItemsPredicate = truthyArrayItemsPredicate; |
@@ -9,1 +9,3 @@ export { useFirstMountState } from './useFirstMountState'; | ||
export { useIsMounted } from './useIsMounted'; | ||
export { useConditionalEffect } from './useConditionalEffect'; | ||
export { useConditionalUpdateEffect } from './useConditionalUpdateEffect'; |
@@ -9,1 +9,3 @@ export { useFirstMountState } from './useFirstMountState'; | ||
export { useIsMounted } from './useIsMounted'; | ||
export { useConditionalEffect } from './useConditionalEffect'; | ||
export { useConditionalUpdateEffect } from './useConditionalUpdateEffect'; |
import { useEffect } from 'react'; | ||
import { useFirstMountState } from './useFirstMountState'; | ||
import { noop } from './util/const'; | ||
/** | ||
@@ -11,9 +12,4 @@ * Effect hook that ignores the first render (not invoked on mount). | ||
var isFirstMount = useFirstMountState(); | ||
// eslint-disable-next-line consistent-return | ||
useEffect(function () { | ||
if (!isFirstMount) { | ||
return effect(); | ||
} | ||
// eslint-disable-next-line react-hooks/exhaustive-deps | ||
}, deps); | ||
// eslint-disable-next-line react-hooks/exhaustive-deps | ||
useEffect(isFirstMount ? noop : effect, deps); | ||
} |
export declare const noop: () => void; | ||
export declare const isBrowser: boolean; | ||
export declare function truthyArrayItemsPredicate(conditions: ReadonlyArray<any>): boolean; |
@@ -5,1 +5,5 @@ export var noop = function () { }; | ||
typeof document !== 'undefined'; | ||
// eslint-disable-next-line @typescript-eslint/no-explicit-any | ||
export function truthyArrayItemsPredicate(conditions) { | ||
return conditions.every(function (i) { return Boolean(i); }); | ||
} |
@@ -9,1 +9,3 @@ export { useFirstMountState } from './useFirstMountState'; | ||
export { useIsMounted } from './useIsMounted'; | ||
export { useConditionalEffect } from './useConditionalEffect'; | ||
export { useConditionalUpdateEffect } from './useConditionalUpdateEffect'; |
@@ -9,1 +9,3 @@ export { useFirstMountState } from './useFirstMountState'; | ||
export { useIsMounted } from './useIsMounted'; | ||
export { useConditionalEffect } from './useConditionalEffect'; | ||
export { useConditionalUpdateEffect } from './useConditionalUpdateEffect'; |
import { useEffect } from 'react'; | ||
import { useFirstMountState } from './useFirstMountState'; | ||
import { noop } from './util/const'; | ||
/** | ||
@@ -11,9 +12,4 @@ * Effect hook that ignores the first render (not invoked on mount). | ||
const isFirstMount = useFirstMountState(); | ||
// eslint-disable-next-line consistent-return | ||
useEffect(() => { | ||
if (!isFirstMount) { | ||
return effect(); | ||
} | ||
// eslint-disable-next-line react-hooks/exhaustive-deps | ||
}, deps); | ||
// eslint-disable-next-line react-hooks/exhaustive-deps | ||
useEffect(isFirstMount ? noop : effect, deps); | ||
} |
export declare const noop: () => void; | ||
export declare const isBrowser: boolean; | ||
export declare function truthyArrayItemsPredicate(conditions: ReadonlyArray<any>): boolean; |
@@ -5,1 +5,5 @@ export const noop = () => { }; | ||
typeof document !== 'undefined'; | ||
// eslint-disable-next-line @typescript-eslint/no-explicit-any | ||
export function truthyArrayItemsPredicate(conditions) { | ||
return conditions.every((i) => Boolean(i)); | ||
} |
{ | ||
"name": "@react-hookz/web", | ||
"version": "1.9.1", | ||
"version": "1.10.0", | ||
"description": "React hooks done right, for browser and SSR.", | ||
@@ -5,0 +5,0 @@ "keywords": [ |
@@ -65,2 +65,6 @@ # ![@react-hookz/web](.github/logo.png) | ||
— Effect hook that ignores the first render (not invoked on mount). | ||
- [`useConditionalEffect`](https://react-hookz.github.io/web/?path=/docs/lifecycle-useconditionaleffect) | ||
— Like `useEffect` but callback invoked only if conditions match predicate. | ||
- [`useConditionalUpdateEffect`](https://react-hookz.github.io/web/?path=/docs/lifecycle-useconditionalupdateeffect) | ||
— Like `useUpdateEffect` but callback invoked only if conditions match predicate. | ||
- #### State | ||
@@ -67,0 +71,0 @@ - [`useToggle`](https://react-hookz.github.io/web/?path=/docs/lifecycle-usetoggle) |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
55287
81
935
74