Skip to content

Commit ae53bac

Browse files
committed
updated componentBuilder in DemoRender to handle arrays in innerText
1 parent 81f1a5f commit ae53bac

File tree

1 file changed

+9
-0
lines changed

1 file changed

+9
-0
lines changed

app/src/components/main/DemoRender.tsx

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,15 @@ const DemoRender = (props): JSX.Element => {
3636
renderedChildren = componentBuilder(element.children);
3737
}
3838
// check if array was used -> write a forEach / for
39+
if (Array.isArray(innerText)) {
40+
innerText.forEach(el => {
41+
const elementCopy = JSON.parse(JSON.stringify(element));
42+
elementCopy.attributes.compText = el;
43+
componentsToRender.push(componentBuilder([elementCopy], key++));
44+
});
45+
continue;
46+
}
47+
3948
if (elementType === 'input') componentsToRender.push(<Box component={elementType} className={classRender} style={elementStyle} key={key} id={`rend${childId}`}></Box>);
4049
else if (elementType === 'img') componentsToRender.push(<Box component={elementType} src={activeLink} className={classRender} style={elementStyle} key={key} id={`rend${childId}`}></Box>);
4150
else if (elementType === 'a') componentsToRender.push(<Box component={elementType} href={activeLink} className={classRender} style={elementStyle} key={key} id={`rend${childId}`}>{innerText}</Box>);

0 commit comments

Comments
 (0)