Files
freeCodeCamp/guide/english/certifications/front-end-libraries/react/compose-react-components/index.md
Randell Dawson 1494a50123 fix(guide): restructure curriculum guide articles (#36501)
* fix: restructure certifications guide articles
* fix: added 3 dashes line before prob expl
* fix: added 3 dashes line before hints
* fix: added 3 dashes line before solutions
2019-07-24 13:29:27 +05:30

1004 B

title
title
Compose React Components

Compose React Components


Hints

Hint 1

Use nested components as in the previous challenge to render components.


Solutions

Solution 1 (Click to Show/Hide)

The following is the solution to the challenge, where it render Citrus and NonCitrus in a component which is then rendered in another:

class Fruits extends React.Component {
  constructor(props) {
    super(props);
  }
  render() {
    return (
      <div>
        <h2>Fruits:</h2>
        <NonCitrus />
        <Citrus />
      </div>
    );
  }
};

class TypesOfFood extends React.Component {
  constructor(props) {
     super(props);
  }
  render() {
    return (
      <div>
        <Fruits />
        <Vegetables />
      </div>
    );
  }
};