Skip to content

Commit

Permalink
+ useDepEffect alias for useEffect2
Browse files Browse the repository at this point in the history
! missing dependency: `@ezez/utils`
  • Loading branch information
dzek69 committed Mar 4, 2024
1 parent 64d016e commit 0ad510e
Show file tree
Hide file tree
Showing 5 changed files with 16 additions and 7 deletions.
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,12 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.
## [UNRELEASED]
(nothing yet)

## [2.1.0] - 2024-03-03
### Added
- `useDepEffect` alias for `useEffect2`
### Fixed
- missing dependency: `@ezez/utils`

## [2.0.0] - 2023-12-30
### Breaking
- `useEffect2` will trigger the callback whenever the dependency array size change, this is different from `useEffect`,
Expand Down
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@ezez/hooks",
"version": "2.0.0",
"version": "2.1.0",
"repository": "[email protected]:dzek69/ezez-hooks.git",
"author": "Jacek Nowacki",
"license": "MIT",
Expand Down Expand Up @@ -33,6 +33,7 @@
"types": "./esm/index.d.ts",
"module": "./esm/index.js",
"dependencies": {
"@ezez/utils": "^1.9.0",
"oop-timers": "^5.0.0"
},
"devDependencies": {
Expand All @@ -44,7 +45,6 @@
"@dzek69/eslint-config-import-typescript": "^1.0.1",
"@dzek69/eslint-config-react": "^1.2.2",
"@dzek69/eslint-config-typescript": "^1.1.1",
"@ezez/utils": "^1.9.0",
"@knodes/typedoc-plugin-pages": "^0.23.4",
"@types/jest": "^29.5.2",
"@types/react": "^18.2.8",
Expand Down
8 changes: 4 additions & 4 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion src/pages/_app.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import { InputDeviceProvider } from "../useInputDevice.js";
const MyApp = ({ Component, pageProps }: AppProps) => (
<>
<Head>
<title>@ezez/utils</title>
<title>@ezez/hooks</title>
</Head>
<InputDeviceProvider>
<Component {...pageProps} />
Expand Down
3 changes: 3 additions & 0 deletions src/useEffect2.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ const shallowCompareArrays = <T extends readonly any[]>(a: T, b: T) => { // esli
* @param dependencies - array of dependencies
*
* @example
* ```typescript
* const { isAdmin, name } = useUserData(); // isAdmin is boolean, name is string
*
* useEffect2((prev) => {
Expand All @@ -40,6 +41,7 @@ const shallowCompareArrays = <T extends readonly any[]>(a: T, b: T) => { // esli
* }
* alert(message);
* }, [isAdmin, name] as const);
* ```
*/
const useEffect2 = <P, T extends (Readonly<P[]>)>(
// eslint-disable-next-line @typescript-eslint/no-invalid-void-type
Expand All @@ -59,4 +61,5 @@ const useEffect2 = <P, T extends (Readonly<P[]>)>(

export {
useEffect2,
useEffect2 as useDepEffect,
};

0 comments on commit 0ad510e

Please sign in to comment.