Skip to content

Commit 743eea9

Browse files
committed
feat: 🎸 Major update
BREAKING CHANGE: 🧨 structure and hooks names changes
1 parent 64e563d commit 743eea9

24 files changed

+92
-41
lines changed

src/hooks/index.ts

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
export * from "./use-deps-change";
2+
export * from "./use-did-mount";
3+
export * from "./use-did-update";
4+
export * from "./use-force-update";
5+
export * from "./use-is-mounted";
6+
export * from "./use-layout-mount";
7+
export * from "./use-layout-update";
8+
export * from "./use-will-mount";
9+
export * from "./use-will-unmount";

src/hooks/use-deps-change/index.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
export * from "./use-deps-change.hook";

src/hooks/use-did-change.hook.ts renamed to src/hooks/use-deps-change/use-deps-change.hook.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import { useEffect, useRef } from "react";
22

3-
export const useDidChange = <T extends unknown[]>(
4-
callback: (previousDependencies: T | null) => void,
3+
export const useDepsChange = <T extends any[]>(
4+
callback: VoidFunction | ((previousDependencies: T | null) => VoidFunction),
55
dependencies: T,
66
useOnMount = false,
77
) => {

src/hooks/use-did-mount.hook.ts

Lines changed: 0 additions & 6 deletions
This file was deleted.

src/hooks/use-did-mount/index.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
export * from "./use-did-mount.hook";
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
/* eslint-disable react-hooks/exhaustive-deps */
2+
import { useEffect, useRef } from "react";
3+
4+
export const useDidMount = (callback: VoidFunction | (() => VoidFunction)) => {
5+
const mounted = useRef(false);
6+
7+
useEffect(() => {
8+
if (!mounted.current) {
9+
mounted.current = true;
10+
return callback();
11+
}
12+
}, []);
13+
};

src/hooks/use-did-update/index.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
export * from "./use-did-update.hook";

src/hooks/use-did-update.hook.ts renamed to src/hooks/use-did-update/use-did-update.hook.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,9 @@
22
import { useEffect, useRef } from "react";
33

44
export const useDidUpdate = (
5-
callback: () => void,
6-
dependencies: readonly unknown[],
5+
callback: VoidFunction | (() => VoidFunction),
6+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
7+
dependencies: any[],
78
useOnMount = false,
89
) => {
910
const mountRef = useRef(useOnMount);

src/hooks/use-force-update.hook.ts

Lines changed: 0 additions & 7 deletions
This file was deleted.

src/hooks/use-force-update/index.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
export * from "./use-force-update.hook";

0 commit comments

Comments
 (0)