Skip to content

Commit 012f7d4

Browse files
authored
Fixed mapDispatchToProps example with parentheses (#1537)
To return an object using the arrow function, wrap the return value in parentheses.
1 parent d8070ab commit 012f7d4

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

docs/api/connect.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -124,9 +124,9 @@ The second parameter is normally referred to as `ownProps` by convention.
124124
<button onClick={() => this.props.toggleTodo(this.props.todoId)} />
125125

126126
// binds on `props` change
127-
const mapDispatchToProps = (dispatch, ownProps) => {
127+
const mapDispatchToProps = (dispatch, ownProps) => ({
128128
toggleTodo: () => dispatch(toggleTodo(ownProps.todoId))
129-
}
129+
})
130130
```
131131
132132
The number of declared function parameters of `mapDispatchToProps` determines whether they receive ownProps. See notes [here](#the-arity-of-maptoprops-functions).

0 commit comments

Comments
 (0)