Skip to content

Commit 5956eb8

Browse files
authored
Merge pull request #14 from oslabs-beta/Miko
fixed multiple pages rendering error
2 parents 3abdbdf + 72e88f6 commit 5956eb8

File tree

2 files changed

+9
-14
lines changed

2 files changed

+9
-14
lines changed

app/src/components/main/AddLink.tsx

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,13 @@ function AddLink({ id }: AddRoutes) {
2626
const handlePageSelect = event => {
2727
const selectedPageName = event.target.value;
2828
console.log('selectedPages State: ', selectedPageName);
29+
console.log('page state', state.components[0].children);
30+
state.components[0].children.forEach(element => {
31+
if(element.childId === id) {
32+
element.attributes.compLink = event.target.value;
33+
}
34+
});
35+
// selectedPageName.compLink = event.target.value;
2936
// dispatch({ type: 'HREF TO', payload: });
3037
}
3138

app/src/components/main/DemoRender.tsx

Lines changed: 2 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -78,24 +78,12 @@ const DemoRender = (): JSX.Element => {
7878
};
7979

8080
let code = '';
81-
//compone
82-
83-
componentBuilder(state.components[0].children).forEach((element, index) => {
84-
// if(element.props.component === 'Link') {
85-
// return;
86-
// // element.props.component = 'a';
87-
// // element.props.id = `rend${6}`;
88-
// } else if(typeof element.type === 'function') {
89-
// return;
90-
// }
91-
console.log('element' + index, element);
92-
console.log('component' + index, state.components[0].children[index * 2 + 1]);
81+
const currComponent = state.components.filter(element => element.id === state.canvasFocus.componentId);
82+
componentBuilder(currComponent[0].children).forEach(element => {
9383
try{
9484
if(element.props.component === 'Link') {
9585

9686
}
97-
// element.props.component = 'a';
98-
// element.props.id = `rend${6}`;
9987
code += ReactDOMServer.renderToString(element)
10088
} catch {
10189
return;

0 commit comments

Comments
 (0)