Skip to content

Commit 9410d17

Browse files
authored
Update README with more examples
1 parent 54af55f commit 9410d17

File tree

1 file changed

+10
-5
lines changed

1 file changed

+10
-5
lines changed

README.md

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -49,24 +49,29 @@ Creates a higher order component and provides the [ComponentAPI](#ComponentAPI)
4949

5050
##### `withMessages(Component)`
5151
Wraps the given `Component` and passes down the [ComponentAPI](#ComponentAPI).
52+
```js
53+
export default withMessages(MyComponent)
54+
```
5255

5356
##### `withMessages(keyPrefix?: string)(Component)`
5457
Similar like the example above, but in a curried format. Useful when decorating a `Component` with many higher order components:
5558
```js
56-
compose(
59+
export default compose(
5760
connect(mapStateToProps, mapDispatchToProps),
5861
withRouter,
5962
withMessages,
60-
)(Component)
63+
)(MyComponent)
6164
```
6265
Additionally, the curried form of `withMessages` accepts an optional `keyPefix` which will be prepended before any translation lookup key (see the examples below). This feature comes quite useful when i18n-ing scoped presentational components.
63-
6466
```js
65-
compose(
67+
export default compose(
6668
connect(mapStateToProps, mapDispatchToProps),
6769
withRouter,
6870
withMessages('app.screens.userProfile'), // scoped lookup
69-
)(Component)
71+
)(MyComponent)
72+
73+
// alternatively
74+
export default withMessages('app.screens.userProfile')(MyComponent)
7075
```
7176

7277
## `ComponentAPI`

0 commit comments

Comments
 (0)