@@ -66,10 +66,10 @@ const DemoRender = (): JSX.Element => {
66
66
}
67
67
if ( elementType === 'input' ) componentsToRender . push ( < Box component = { elementType } className = { classRender } style = { elementStyle } key = { key } id = { `rend${ childId } ` } > </ Box > ) ;
68
68
else if ( elementType === 'img' ) componentsToRender . push ( < Box component = { elementType } src = { activeLink } className = { classRender } style = { elementStyle } key = { key } id = { `rend${ childId } ` } > </ Box > ) ;
69
- else if ( elementType === 'a' ) componentsToRender . push ( < Box component = { elementType } href = { activeLink } className = { classRender } style = { elementStyle } key = { key } id = { `rend${ childId } ` } > { innerText } </ Box > ) ;
69
+ else if ( elementType === 'a' || elementType === 'Link' ) componentsToRender . push ( < Box component = { 'a' } href = { activeLink } className = { classRender } style = { elementStyle } key = { key } id = { `rend${ childId } ` } > { innerText } </ Box > ) ;
70
70
else if ( elementType === 'Switch' ) componentsToRender . push ( < Switch > { renderedChildren } </ Switch > ) ;
71
71
else if ( elementType === 'Route' ) componentsToRender . push ( < Route exact path = { activeLink } > { renderedChildren } </ Route > ) ;
72
- else if ( elementType === 'LinkTo' ) componentsToRender . push ( < Link to = { activeLink } > { innerText } </ Link > ) ;
72
+ // else if (elementType === 'LinkTo') componentsToRender.push(<Link to={activeLink}>{innerText}</Link>);
73
73
else componentsToRender . push ( < Box component = { elementType } className = { classRender } style = { elementStyle } key = { key } id = { `rend${ childId } ` } > { innerText } { renderedChildren } </ Box > ) ;
74
74
key += 1 ;
75
75
}
@@ -80,26 +80,28 @@ const DemoRender = (): JSX.Element => {
80
80
let code = '' ;
81
81
//compone
82
82
83
- componentBuilder ( state . components [ 0 ] . children ) . forEach ( element => {
84
- if ( element . props . component === 'Link' ) {
85
- return ;
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 ] ) ;
93
+ try {
94
+ if ( element . props . component === 'Link' ) {
95
+
96
+ }
86
97
// element.props.component = 'a';
87
98
// element.props.id = `rend${6}`;
88
- } else if ( typeof element . type === 'function' ) {
99
+ code += ReactDOMServer . renderToString ( element )
100
+ } catch {
89
101
return ;
90
102
}
91
- code += ReactDOMServer . renderToString ( element )
92
103
} ) ;
93
104
94
- // state.components[0].children?.forEach(element => {
95
- // if(element.name === 'Switch' || element.name === 'Link') {
96
- // element.name = 'a';
97
- // element.typeId = 6;
98
- // }
99
- // console.log(element)
100
- // });
101
- // console.log('code', code);
102
-
103
105
useEffect ( ( ) => {
104
106
cssRefresher ( ) ;
105
107
} , [ ] )
0 commit comments