Skip to content

Commit 99f64d3

Browse files
more thurough testing complete, fixed prop passing by ignoring html elements, will add onclick stuff later
1 parent 08b9c94 commit 99f64d3

File tree

1 file changed

+12
-6
lines changed

1 file changed

+12
-6
lines changed

src/utils/componentRender.util.js

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,17 @@ const componentRender = (component, data) => {
3333
return 'any';
3434
}
3535
}
36+
37+
function propDrillTextGenerator(child) {
38+
if (child.childType === 'COMP') {
39+
return data
40+
.find(c => c.id === child.childComponentId)
41+
.props.map(prop => `${prop.key}={${prop.value}}`)
42+
.join(' ');
43+
}
44+
return '';
45+
}
46+
3647
// need to filter with reduce the import, copy from below
3748
if (stateful) {
3849
return `
@@ -88,12 +99,7 @@ const componentRender = (component, data) => {
8899
const ${title} = (props: Props) => (
89100
<div>
90101
${childrenArray
91-
.map(
92-
child => `<${child.componentName} ${data
93-
.find(c => c.id === child.childComponentId)
94-
.props.map(prop => `${prop.key}={${prop.value}}`)
95-
.join(' ')}/>`,
96-
)
102+
.map(child => `<${child.componentName} ${propDrillTextGenerator(child)}/>`)
97103
.join('\n')}
98104
</div>
99105
);

0 commit comments

Comments
 (0)