Skip to content

Commit

Permalink
Merge pull request #5 from ImLunaHey/main
Browse files Browse the repository at this point in the history
fix: incorrect hook types
  • Loading branch information
prc5 authored Nov 8, 2023
2 parents 727d377 + e218de9 commit 64e563d
Show file tree
Hide file tree
Showing 5 changed files with 7 additions and 7 deletions.
4 changes: 2 additions & 2 deletions src/hooks/use-did-change.hook.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { useEffect, useRef } from "react";

export const useDidChange = <T extends any[]>(
callback: VoidFunction | ((previousDependencies: T | null) => VoidFunction),
export const useDidChange = <T extends unknown[]>(
callback: (previousDependencies: T | null) => void,
dependencies: T,
useOnMount = false,
) => {
Expand Down
2 changes: 1 addition & 1 deletion src/hooks/use-did-mount.hook.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/* eslint-disable react-hooks/exhaustive-deps */
import { useEffect } from "react";

export const useDidMount = (callback: VoidFunction | (() => VoidFunction)) => {
export const useDidMount = (callback: () => void) => {
useEffect(callback, []);
};
4 changes: 2 additions & 2 deletions src/hooks/use-did-update.hook.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@
import { useEffect, useRef } from "react";

export const useDidUpdate = (
callback: VoidFunction | (() => VoidFunction),
dependencies: any[],
callback: () => void,
dependencies: readonly unknown[],
useOnMount = false,
) => {
const mountRef = useRef(useOnMount);
Expand Down
2 changes: 1 addition & 1 deletion src/hooks/use-will-mount.hook.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { useState } from "react";

export const useWillMount = (callback: VoidFunction) => {
export const useWillMount = (callback: () => void) => {
useState(callback);
};
2 changes: 1 addition & 1 deletion src/hooks/use-will-unmount.hook.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/* eslint-disable react-hooks/exhaustive-deps */
import { useEffect } from "react";

export const useWillUnmount = (callback: VoidFunction) => {
export const useWillUnmount = (callback: () => void) => {
useEffect(() => callback, []);
};

0 comments on commit 64e563d

Please sign in to comment.