Tell us what’s happening:
Am I wrong in assuming that there is unnecessary pregenerated code in this challenge? Or, is it necessary to render the Fruits class component and then render it again in the TypesOfFood class component?
Your code so far
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>
<h1>Types of Food:</h1>
<Fruits />
<Vegetables />
</div>
);
}
};
Wouldn’t the Fruits component just simplify to:
const Fruits = () => {
return (
<div>
<h2>Fruits:</h2>
<NonCitrus />
<Citrus />
</div>
);
};
class TypesOfFood extends React.Component {
constructor(props) {
super(props);
}
render() {
return (
<div>
<h1>Types of Food:</h1>
<Fruits />
<Vegetables />
</div>
);
}
};
And then get rendered by the TypesOfFood class component? I tried the simplified version above and it also passed the challenge. Is there any reason to render both components other than you might run into a case where you want to render Fruits by itself and not within TypesOfFood?
Link to the challenge:
https://learn.freecodecamp.org/front-end-libraries/react/compose-react-components