Hello, I’m running a custom JavaScript code on my app that builds a complex JSON object based on an array of elements that are related to each other hierarchically, but I’m facing a bug or issue or limitation that freezes the WeWeb editor.
Anyone else had this issue? Or maybe someone from WeWeb to shed some light on the matter?
It looks to me like something that won’t matter after deploying, but it’s a major issue for development.
The browser console log shows the following message:
This happens when I click on to edit the workflow below:
The code I’m executing is composed of two javascript functions and an action to store the result of the second function on a variable. Only this second javascript code has a recursion, that executes 8 times with the test data:
const json_build_function = (
blocks,
parent = null
) => {
// If parent is null, get the main parent
if (!parent) {
parent = blocks.find(item => (item.parent_id==null));
}
// Get children from the parent
const children = blocks
.filter(item => (item.parent_id==parent.id))
.sort((a,b) => (a.order - b.order));
// Process children of children
if (children.length > 0) {
parent.children = children.map(child => {
const children = json_build_function(blocks, child);
if (children) Object.assign(child.children, children);
return child;
})
} else {
return undefined;
}
// Retorn parent
return parent
}