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

57 lines
1004 B
Markdown

---
title: Compose React Components
---
# Compose React Components
---
## Hints
### Hint 1
Use nested components as in the previous challenge to render components.
---
## Solutions
<details><summary>Solution 1 (Click to Show/Hide)</summary>
The following is the solution to the challenge, where it render `Citrus` and `NonCitrus` in a component which is then rendered in another:
```jsx
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>
);
}
};
```
#### Relevant Links
- [Components and Props](https://reactjs.org/docs/components-and-props.html)
- [Nested Components](http://www.reactjstutorial.net/nested-components.html)
</details>