Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(@nf-team/react): useThrottleCallback arg type error #62

Merged
merged 1 commit into from
Nov 18, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .changeset/cool-chefs-cheer.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@nf-team/react": patch
---

fix(@nf-team/react): useThrottleCallback arg type error
2 changes: 1 addition & 1 deletion packages/react/src/hooks/useThrottleCallback.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { DependencyList, useCallback, useRef } from 'react';

function useThrottleCallback<U extends never[]>(
function useThrottleCallback<U extends unknown[] = []>(
callback: (...args: U) => void,
dependencyList: DependencyList,
delay: number,
Expand All @@ -14,7 +14,7 @@
timer.current = null;
}, delay);
}
}, [...dependencyList, delay]);

Check warning on line 17 in packages/react/src/hooks/useThrottleCallback.ts

View workflow job for this annotation

GitHub Actions / check unit test & lint

React Hook useCallback has a missing dependency: 'callback'. Either include it or remove the dependency array. If 'callback' changes too often, find the parent component that defines it and wrap that definition in useCallback

Check warning on line 17 in packages/react/src/hooks/useThrottleCallback.ts

View workflow job for this annotation

GitHub Actions / check unit test & lint

React Hook useCallback has a spread element in its dependency array. This means we can't statically verify whether you've passed the correct dependencies

return throttledCallback;
}
Expand Down
Loading