Skip to content

Commit fcd8402

Browse files
committedMar 10, 2020
function components
1 parent d55848b commit fcd8402

File tree

6 files changed

+8298
-6352
lines changed

6 files changed

+8298
-6352
lines changed
 

‎README.md

+6-36
Original file line numberDiff line numberDiff line change
@@ -2,42 +2,12 @@
22

33
[![Build Status](https://travis-ci.org/the-road-to-learn-react/react-composability-over-configurability.svg?branch=master)](https://travis-ci.org/the-road-to-learn-react/react-composability-over-configurability) [![Slack](https://slack-the-road-to-learn-react.wieruch.com/badge.svg)](https://slack-the-road-to-learn-react.wieruch.com/) [![Greenkeeper badge](https://badges.greenkeeper.io/the-road-to-learn-react/react-composability-over-configurability.svg)](https://greenkeeper.io/)
44

5-
React gives you the power of composing components into each other with its children prop. You should make use of it rather than passing "configurational" props to one complex component. That way you keep your components lightweight and give yourself lots of flexibility for adjustments.
6-
7-
```
8-
const OPTIONS = [
9-
{ value: 'grapefruit', label: 'Grapefruit' },
10-
{ value: 'lime', label: 'Lime' },
11-
{ value: 'coconut', label: 'Coconut' },
12-
{ value: 'mango', label: 'Mango' },
13-
];
14-
15-
// Configuration
16-
// the Select components has the <select> and <option> elements within one complex component
17-
<Select
18-
value={this.state.value}
19-
options={this.props.options}
20-
handleChange={this.handleChange}
21-
/>
22-
23-
// Composition
24-
// the Select component has only the <select> element
25-
// the Option component has only the <option> element
26-
// advantages: lightweight components, flexible way of composing components into each other
27-
<Select
28-
value={this.state.value}
29-
handleChange={this.handleChange}
30-
>
31-
{this.props.options.map(option =>
32-
<Option key={option.value} {...option} />
33-
)}
34-
</Select>
35-
```
5+
React gives you the power of composing components into each other with its children prop. You should make use of it rather than passing "configurational" props to one complex component. That way you keep your components lightweight and give yourself lots of flexibility for adjustments. [Read more about it.](https://www.robinwieruch.de/react-component-composition)
366

377
## Installation
388

39-
* `git clone git@github.com:the-road-to-learn-react/react-composability-over-configurability.git`
40-
* cd react-composability-over-configurability
41-
* npm install
42-
* npm start
43-
* visit `http://localhost:3000/`
9+
- `git clone git@github.com:the-road-to-learn-react/react-composability-over-configurability.git`
10+
- cd react-composability-over-configurability
11+
- npm install
12+
- npm start
13+
- visit `http://localhost:3000/`

0 commit comments

Comments
 (0)
Please sign in to comment.