Skip to content

Commit 0a6d7e3

Browse files
committed
Document decorators
1 parent d56fa56 commit 0a6d7e3

File tree

1 file changed

+37
-0
lines changed

1 file changed

+37
-0
lines changed

README.md

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -164,6 +164,43 @@ export default class CounterContainer {
164164
}
165165
```
166166

167+
#### Decorators
168+
169+
Don't want to separate dumb and smart components just yet?
170+
Use the decorators.
171+
They work exactly the same as the container components, but are lowercase:
172+
173+
```js
174+
import React, { PropTypes } from 'react';
175+
import { increment, decrement } from './actions/CounterActions';
176+
import { container } from 'redux';
177+
import counterStore from './stores/counterStore';
178+
179+
@container({
180+
actions: { increment, decrement },
181+
stores: counterStore
182+
})
183+
export default class Counter {
184+
static propTypes = {
185+
increment: PropTypes.func.isRequired,
186+
decrement: PropTypes.func.isRequired,
187+
counter: PropTypes.number.isRequired
188+
};
189+
190+
render() {
191+
return (
192+
<p>
193+
Clicked: {this.props.counter} times
194+
{' '}
195+
<button onClick={() => this.props.increment()}>+</button>
196+
{' '}
197+
<button onClick={() => this.props.decrement()}>-</button>
198+
</p>
199+
);
200+
}
201+
}
202+
```
203+
167204
#### The root component
168205

169206
```js

0 commit comments

Comments
 (0)