🐛 fix(ApiModal/index.tsx): fix conditional check for empty nodes array in useEffect hook
✨ feat(ApiModal/index.tsx): add startTweaks function to initialize tweaks when nodes array is not empty
This commit is contained in:
parent
290ef87247
commit
dde4ed07ef
1 changed files with 27 additions and 0 deletions
|
|
@ -107,6 +107,33 @@ const ApiModal = forwardRef(
|
||||||
},
|
},
|
||||||
];
|
];
|
||||||
|
|
||||||
|
useEffect(() => {
|
||||||
|
|
||||||
|
if(flow["data"]["nodes"].length == 0){
|
||||||
|
tweak.current = [];
|
||||||
|
setTweak(tweak.current);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
else{
|
||||||
|
if (tweak.current.length > 0) {
|
||||||
|
tweak.current = getTweak;
|
||||||
|
|
||||||
|
} else {
|
||||||
|
startTweaks();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
}, [flow["data"]["nodes"]]);
|
||||||
|
|
||||||
|
function startTweaks() {
|
||||||
|
const t = buildTweaks(flow);
|
||||||
|
Object.keys(t).length == 0 ? tweak.current = [] : tweak?.current?.push(t);
|
||||||
|
setTweak(tweak.current);
|
||||||
|
}
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
filterNodes();
|
filterNodes();
|
||||||
}, []);
|
}, []);
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue