HOW CAN WE EMBED TWO OR MORE COMPONENTS INTO ONE IN REACT?

How can we embed two or more components into one in React?

We can embed components into one in the following way:

1 class MyComponent extends React.Component{

2 render(){

3 return(

4 <div>

5 <h1>Hello</h1>

6 <Header/>

7 </div>

8 );

9 }

10 }

11 class Header extends React.Component{

12 render(){

13 return <h1>Header Component</h1>

14 };

15 }

16 ReactDOM.render(

17 <MyComponent/>, document.getElementById(‘content’)

18 );

Leave a Reply

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>