Compose React Components
As the challenges continue to use more complex compositions with React components and JSX, there is one important point to note. Rendering ES6 style class components within other components is no different than rendering the simple components you used in the last few challenges. You can render JSX elements, stateless functional components, and ES6 class components within other components.
In the code editor, the TypesOfFood
component is already rendering a component called Vegetables
. Also, there is the Fruits
component from the last challenge.
Nest two components inside of Fruits
— first NonCitrus
, and then Citrus
. Both of these components are provided for you behind the scenes. Next, nest the Fruits
class component into the TypesOfFood
component, below the h1
heading element and above Vegetables
. The result should be a series of nested components, which uses two different component types.
Tests
- Waiting: 1. The
TypesOfFood
component should return a singlediv
element. - Waiting: 2. The
TypesOfFood
component should return theFruits
component. - Waiting: 3. The
Fruits
component should return theNonCitrus
component and theCitrus
component. - Waiting: 4. The
TypesOfFood
component should return theVegetables
component below theFruits
component.
/** * Your test output will go here */