File tree Expand file tree Collapse file tree 2 files changed +2
-13
lines changed Expand file tree Collapse file tree 2 files changed +2
-13
lines changed Original file line number Diff line number Diff line change 11import React , { Component } from "react" ;
22import RecursiveComponent from "./RecursiveComponent" ;
33
4- // write components here
5- // const One and so on...
64const One = ( { children } ) => {
75 return < div className = "box" > One { children } </ div > ;
86} ;
@@ -12,8 +10,6 @@ const Two = ({ children }) => {
1210const Three = ( { children } ) => {
1311 return < div className = "box" > Three { children } </ div > ;
1412} ;
15-
16- // assign components below
1713const components = [ One , Two , Three ] ;
1814
1915export default class Recursion extends Component {
Original file line number Diff line number Diff line change @@ -7,21 +7,14 @@ export default class RecursiveComponent extends Component {
77 this . components = this . props . components ;
88 }
99 recurseThemAll ( ) {
10- return this . props . components . reduceRight (
10+ return this . components . reduceRight (
1111 ( children , NestedComponent ) => (
1212 < NestedComponent > { children } </ NestedComponent >
1313 ) ,
1414 null
1515 ) ;
1616 }
17-
1817 render ( ) {
19- return (
20- < div >
21- { this . recurseThemAll ( ) }
22- { /*this.props.components.map(e => e())*/ }
23- { /* invoke recursive method here */ }
24- </ div >
25- ) ;
18+ return < div > { this . recurseThemAll ( ) } </ div > ;
2619 }
2720}
You can’t perform that action at this time.
0 commit comments