Nested Components
Last updated
Last updated
import React from 'react';
function Comment(props) {
return (
<>
<p>{props.body}</p>
</>
);
}
export default Comment;import React from 'react';
// import the comment component
import Comment from './Comment.js';
function Dino(props) {
let allComments = props.comments.map((c, i)=>{
return <Comment key={i} body={c}/>
});
return (
<>
<h1>Check out my {props.title} blog!</h1>
<p>Written by {props.author}</p>
<p>{props.body}</p>
{allComments}
</>
);
}
export default Dino;