Skip to content

Commit 64e563d

Browse files
authored
Merge pull request #5 from ImLunaHey/main
fix: incorrect hook types
2 parents 727d377 + e218de9 commit 64e563d

5 files changed

+7
-7
lines changed

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

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

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

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
/* eslint-disable react-hooks/exhaustive-deps */
22
import { useEffect } from "react";
33

4-
export const useDidMount = (callback: VoidFunction | (() => VoidFunction)) => {
4+
export const useDidMount = (callback: () => void) => {
55
useEffect(callback, []);
66
};

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

+2-2
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,8 @@
22
import { useEffect, useRef } from "react";
33

44
export const useDidUpdate = (
5-
callback: VoidFunction | (() => VoidFunction),
6-
dependencies: any[],
5+
callback: () => void,
6+
dependencies: readonly unknown[],
77
useOnMount = false,
88
) => {
99
const mountRef = useRef(useOnMount);

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

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import { useState } from "react";
22

3-
export const useWillMount = (callback: VoidFunction) => {
3+
export const useWillMount = (callback: () => void) => {
44
useState(callback);
55
};

src/hooks/use-will-unmount.hook.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
/* eslint-disable react-hooks/exhaustive-deps */
22
import { useEffect } from "react";
33

4-
export const useWillUnmount = (callback: VoidFunction) => {
4+
export const useWillUnmount = (callback: () => void) => {
55
useEffect(() => callback, []);
66
};

0 commit comments

Comments
 (0)