This is a fairly easy lesson, but there was not a direct solution for it, and I thought it’s good to add one same as the other.
Code explanation: Two stateless functional components are called within one another. This is done by calling a component in the form of a self-closing tag in the body of another component. Make sure you include this inside return().
const TypesOfFruit = () => {
return (
<div>
<h2>Fruits:</h2>
<ul>
<li>Apples</li>
<li>Blueberries</li>
<li>Strawberries</li>
<li>Bananas</li>
</ul>
</div>
);
};
const Fruits = () => {
return (
<div>
{ /* change code below this line */ }
<TypesOfFruit/>
{ /* change code above this line */ }
</div>
);
};
class TypesOfFood extends React.Component {
constructor(props) {
super(props);
}
render() {
return (
<div>
<h1>Types of Food:</h1>
{ /* change code below this line */ }
<Fruits/>
{ /* change code above this line */ }
</div>
);
}
};
Lesson link: https://www.freecodecamp.org/learn/front-end-libraries/react/use-react-to-render-nested-components