fix: useRef without parameters

This commit is contained in:
anatawa12 2025-03-02 22:40:46 +09:00
commit ad32047e13
No known key found for this signature in database
GPG key ID: 9CA909848B8E4EA6
2 changed files with 3 additions and 5 deletions

View file

@ -58,7 +58,7 @@ function PageBody() {
queryKey: ["environmentRepositoriesInfo"],
queryFn: commands.environmentRepositoriesInfo,
});
const onFinishAddRepositoryCallbackRef = useRef<() => void>();
const onFinishAddRepositoryCallbackRef = useRef<() => void>(undefined);
const addRepositoryInfo = useAddRepository({
refetch: () => result.refetch(),

View file

@ -7,12 +7,10 @@ import { useCallback, useRef } from "react";
export function useEffectEvent<Args extends unknown[]>(
listener: (...args: Args) => void,
): (...args: Args) => void {
const event = useRef<(...args: Args) => void>();
const event = useRef<(...args: Args) => void>(listener);
event.current = listener;
return useCallback((...args: Args) => {
if (event.current) {
event.current(...args);
}
event.current(...args);
}, []);
}