2
0
mirror of https://github.com/inventree/InvenTree.git synced 2025-07-09 15:10:54 +00:00

Fix useEffect dependencies (#9967)

- Passing an array to a useEffect dependency list apparently is problematic
This commit is contained in:
Oliver
2025-07-07 10:07:34 +10:00
committed by GitHub
parent e19e5eb029
commit 1bbbde0b22
2 changed files with 7 additions and 5 deletions

View File

@ -77,7 +77,7 @@ function BomItemSubstituteRow({
type BomItemSubstituteFormProps = { type BomItemSubstituteFormProps = {
bomItemId: number; bomItemId: number;
substitutes: any[]; bomItem: any;
onClose?: () => void; onClose?: () => void;
}; };
@ -88,8 +88,8 @@ export function useEditBomSubstitutesForm(props: BomItemSubstituteFormProps) {
const [substitutes, setSubstitutes] = useState<any[]>([]); const [substitutes, setSubstitutes] = useState<any[]>([]);
useEffect(() => { useEffect(() => {
setSubstitutes(props.substitutes); setSubstitutes(props.bomItem?.substitutes ?? []);
}, [props.substitutes]); }, [props.bomItem.substitutes]);
const formFields: ApiFormFieldSet = useMemo(() => { const formFields: ApiFormFieldSet = useMemo(() => {
return { return {

View File

@ -428,7 +428,7 @@ export function BomTable({
const editSubstitues = useEditBomSubstitutesForm({ const editSubstitues = useEditBomSubstitutesForm({
bomItemId: selectedBomItem.pk, bomItemId: selectedBomItem.pk,
substitutes: selectedBomItem?.substitutes ?? [], bomItem: selectedBomItem,
onClose: () => { onClose: () => {
table.refreshTable(); table.refreshTable();
} }
@ -501,7 +501,9 @@ export function BomTable({
record.validated || record.validated ||
!user.hasChangeRole(UserRoles.part), !user.hasChangeRole(UserRoles.part),
icon: <IconCircleCheck />, icon: <IconCircleCheck />,
onClick: () => validateBomItem(record) onClick: () => {
validateBomItem(record);
}
}, },
RowEditAction({ RowEditAction({
hidden: partLocked || !user.hasChangeRole(UserRoles.part), hidden: partLocked || !user.hasChangeRole(UserRoles.part),