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

#SHA-22: Fix: ESLint React Hook dependency array warnings #37

Merged
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
3 changes: 3 additions & 0 deletions src/registry/default/extension/breadcrumb.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -134,6 +134,7 @@ export const BreadCrumb = ({
setOpen(!open);
}
},
// eslint-disable-next-line react-hooks/exhaustive-deps
[activeIndex, value, prevValue]
);

Expand Down Expand Up @@ -223,6 +224,7 @@ export const BreadCrumbItem = forwardRef<
return () => {
onPrevValueChange(value);
};
// eslint-disable-next-line react-hooks/exhaustive-deps
}, [index, onValueChange]);

return (
Expand Down Expand Up @@ -285,6 +287,7 @@ export const BreadCrumbEllipsis = forwardRef<
const arr = [...prev, index];
return arr.sort((a, b) => Number(a) - Number(b));
});
// eslint-disable-next-line react-hooks/exhaustive-deps
}, [index, onValueChange]);
return (
<span
Expand Down
1 change: 1 addition & 0 deletions src/registry/default/extension/carousel.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -138,6 +138,7 @@ const Carousel = forwardRef<
break;
}
},
// eslint-disable-next-line react-hooks/exhaustive-deps
[emblaMainApi, orientation, direction]
);

Expand Down
2 changes: 2 additions & 0 deletions src/registry/default/extension/file-upload.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -148,6 +148,7 @@ export const FileUploader = forwardRef<
setActiveIndex(-1);
}
},
// eslint-disable-next-line react-hooks/exhaustive-deps
[value, activeIndex, removeFileFromSet]
);

Expand Down Expand Up @@ -189,6 +190,7 @@ export const FileUploader = forwardRef<
}
}
},
// eslint-disable-next-line react-hooks/exhaustive-deps
[reSelectAll, value]
);

Expand Down
4 changes: 4 additions & 0 deletions src/registry/default/extension/image-carousel-upload.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,7 @@ export function FileUploadCarouselProvider<T>({
return [...(prev || []), fileWithPreview];
});
},
// eslint-disable-next-line react-hooks/exhaustive-deps
[reSelectAll]
);

Expand All @@ -112,6 +113,7 @@ export function FileUploadCarouselProvider<T>({
return newPreview;
});
},
// eslint-disable-next-line react-hooks/exhaustive-deps
[emblaMainApi, activeIndex]
);

Expand All @@ -129,6 +131,7 @@ export function FileUploadCarouselProvider<T>({
dropzoneState.inputRef.current?.click();
}
},
// eslint-disable-next-line react-hooks/exhaustive-deps
[emblaMainApi, activeIndex, removeImageFromPreview]
);

Expand Down Expand Up @@ -162,6 +165,7 @@ export function FileUploadCarouselProvider<T>({
}
}
},
// eslint-disable-next-line react-hooks/exhaustive-deps
[reSelectAll]
);

Expand Down
2 changes: 2 additions & 0 deletions src/registry/default/extension/multi-select.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,7 @@ const MultiSelector = ({
onValueChange([...value, val]);
}
},
// eslint-disable-next-line react-hooks/exhaustive-deps
[value]
);

Expand Down Expand Up @@ -120,6 +121,7 @@ const MultiSelector = ({
}
}
},
// eslint-disable-next-line react-hooks/exhaustive-deps
[value, inputValue, activeIndex, loop]
);

Expand Down
4 changes: 4 additions & 0 deletions src/registry/default/extension/tree-view-api.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -134,6 +134,7 @@ const Tree = forwardRef<HTMLDivElement, TreeViewProps>(
if (initialSelectedId) {
expandSpecificTargetedElements(elements, initialSelectedId);
}
// eslint-disable-next-line react-hooks/exhaustive-deps
}, [initialSelectedId, elements]);

const direction = dir === "rtl" ? "rtl" : "ltr";
Expand Down Expand Up @@ -355,17 +356,20 @@ const CollapseButton = forwardRef<
};

elements.forEach(expandTree);
// eslint-disable-next-line react-hooks/exhaustive-deps
}, []);

const closeAll = useCallback(() => {
setExpendedItems?.([]);
// eslint-disable-next-line react-hooks/exhaustive-deps
}, []);

useEffect(() => {
console.log(expandAll);
if (expandAll) {
expendAllTree(elements);
}
// eslint-disable-next-line react-hooks/exhaustive-deps
}, [expandAll]);

return (
Expand Down