fix: resolve all 25 ESLint react-hooks and react-refresh violations
Replace useEffect-based state resets in dialogs with React's render-time state adjustment pattern. Wrap ref assignments in hooks with useEffect. Suppress known third-party library warnings (shadcn CVA exports, TanStack Table). Remove warn downgrades from eslint config.
This commit was merged in pull request #1.
This commit is contained in:
@@ -53,18 +53,29 @@ export function useCreateSnapshot() {
|
||||
});
|
||||
|
||||
useEffect(() => {
|
||||
const unlistenPromise = onSnapshotProgress((p) => {
|
||||
if (p.snapshot_id === snapshotIdRef.current) {
|
||||
let mounted = true;
|
||||
let unlisten: (() => void) | undefined;
|
||||
onSnapshotProgress((p) => {
|
||||
if (mounted && p.snapshot_id === snapshotIdRef.current) {
|
||||
setProgress(p);
|
||||
}
|
||||
}).then((fn) => {
|
||||
if (mounted) {
|
||||
unlisten = fn;
|
||||
} else {
|
||||
fn();
|
||||
}
|
||||
});
|
||||
return () => {
|
||||
unlistenPromise.then((unlisten) => unlisten());
|
||||
mounted = false;
|
||||
unlisten?.();
|
||||
};
|
||||
}, []);
|
||||
|
||||
const mutationRef = useRef(mutation);
|
||||
mutationRef.current = mutation;
|
||||
useEffect(() => {
|
||||
mutationRef.current = mutation;
|
||||
});
|
||||
|
||||
const reset = useCallback(() => {
|
||||
mutationRef.current.reset();
|
||||
@@ -101,18 +112,29 @@ export function useRestoreSnapshot() {
|
||||
});
|
||||
|
||||
useEffect(() => {
|
||||
const unlistenPromise = onSnapshotProgress((p) => {
|
||||
if (p.snapshot_id === snapshotIdRef.current) {
|
||||
let mounted = true;
|
||||
let unlisten: (() => void) | undefined;
|
||||
onSnapshotProgress((p) => {
|
||||
if (mounted && p.snapshot_id === snapshotIdRef.current) {
|
||||
setProgress(p);
|
||||
}
|
||||
}).then((fn) => {
|
||||
if (mounted) {
|
||||
unlisten = fn;
|
||||
} else {
|
||||
fn();
|
||||
}
|
||||
});
|
||||
return () => {
|
||||
unlistenPromise.then((unlisten) => unlisten());
|
||||
mounted = false;
|
||||
unlisten?.();
|
||||
};
|
||||
}, []);
|
||||
|
||||
const mutationRef = useRef(mutation);
|
||||
mutationRef.current = mutation;
|
||||
useEffect(() => {
|
||||
mutationRef.current = mutation;
|
||||
});
|
||||
|
||||
const reset = useCallback(() => {
|
||||
mutationRef.current.reset();
|
||||
|
||||
Reference in New Issue
Block a user