Skip to content

Commit f0bbf49

Browse files
committed
note about wrapping
1 parent db0e613 commit f0bbf49

File tree

1 file changed

+18
-0
lines changed

1 file changed

+18
-0
lines changed

README.md

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,3 +65,21 @@ class App extends React.Component {
6565
}
6666
}
6767
```
68+
69+
You may prefer to wrap these components into channel specific pairs to avoid typos and other problems with the indirection involved with the channel strings:
70+
71+
```js
72+
const CHANNEL = 'currentUser'
73+
const BroadcastCurrentUser = (props) =>
74+
<Broadcast channel={CHANNEL} {...props} />
75+
76+
const CurrentUserSubscriber = (props) =>
77+
<Subscriber channel={CHANNEL} {...props} />
78+
79+
export { BroadcastCurrentUser, CurrentUserSubscriber }
80+
81+
// then use them across the app like so:
82+
<BroadcastCurrentUser value={user}/>
83+
<CurrentUserSubscriber>{(user) => ()}</CurrentUserSubscriber>
84+
```
85+

0 commit comments

Comments
 (0)