Used data to trigger table re-render

This commit is contained in:
Lucas Oliveira 2024-06-06 10:46:40 -03:00
commit e9fc02f700
3 changed files with 9 additions and 10 deletions

View file

@ -4,7 +4,6 @@ import TableAutoCellRender from "../../../components/tableComponent/components/t
import TableNodeCellRender from "../../../components/tableComponent/components/tableNodeCellRender";
import TableToggleCellRender from "../../../components/tableComponent/components/tableToggleCellRender";
import TableTooltipRender from "../../../components/tableComponent/components/tableTooltipRender";
import TableMultilineCellRender from "../../../components/tableComponent/components/tableMultilineCellRender";
const useColumnDefs = (
myData: any,
@ -51,10 +50,10 @@ const useColumnDefs = (
valueGetter: (params: ValueGetterParams) => {
return {
value: params.data.value,
nodeClass: myData.current.node,
nodeClass: myData.node,
handleOnNewValue: handleOnNewValue,
handleOnChangeDb: (value, key) => {
myData.current.node!.template[key].load_from_db = value;
myData.node!.template[key].load_from_db = value;
},
};
},
@ -83,7 +82,7 @@ const useColumnDefs = (
cellClass: "no-border",
},
],
[open],
[open, myData],
);
return columnDefs;

View file

@ -4,9 +4,9 @@ import { TemplateVariableType } from "../../../types/api";
const useRowData = (myData, open) => {
const rowData = useMemo(() => {
return Object.keys(myData.current.node!.template)
return Object.keys(myData.node!.template)
.filter((key: string) => {
const templateParam = myData.current.node!.template[
const templateParam = myData.node!.template[
key
] as TemplateVariableType;
return (
@ -20,7 +20,7 @@ const useRowData = (myData, open) => {
);
})
.map((key: string) => {
const templateParam = myData.current.node!.template[
const templateParam = myData.node!.template[
key
] as TemplateVariableType;
return {
@ -29,7 +29,7 @@ const useRowData = (myData, open) => {
id: key,
};
});
}, [open]);
}, [open, myData]);
return rowData;
};

View file

@ -38,10 +38,10 @@ const EditNodeModal = forwardRef(
myData.current.node!.template[name].value = newValue;
};
const rowData = useRowData(myData, open);
const rowData = useRowData(data, open);
const columnDefs: ColDef[] = useColumnDefs(
myData,
data,
handleOnNewValue,
changeAdvanced,
open,