Skip to content

Commit 13667e1

Browse files
author
Michael Jackson
committed
Make <Subscriber children> optional
1 parent 75ad603 commit 13667e1

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

modules/Subscriber.js

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ import invariant from "invariant"
99
class Subscriber extends React.Component {
1010
static propTypes = {
1111
channel: PropTypes.string.isRequired,
12-
children: PropTypes.func.isRequired
12+
children: PropTypes.func,
1313
}
1414

1515
static contextTypes = {
@@ -51,7 +51,8 @@ class Subscriber extends React.Component {
5151
}
5252

5353
render() {
54-
return this.props.children(this.state.value)
54+
const { children } = this.props
55+
return children ? children(this.state.value) : null
5556
}
5657
}
5758

0 commit comments

Comments
 (0)