Skip to content

Commit 3760cc3

Browse files
mudrztimdorr
authored andcommitted
Add dispatch shorthand example to documentation (reduxjs#804)
* Add dispatch shorthand example to documentation * Update api.md removed rename, simplified comment * Cleanups
1 parent 1d08bdf commit 3760cc3

File tree

1 file changed

+16
-0
lines changed

1 file changed

+16
-0
lines changed

docs/api.md

+16
Original file line numberDiff line numberDiff line change
@@ -218,6 +218,22 @@ function mapDispatchToProps(dispatch) {
218218
export default connect(mapStateToProps, mapDispatchToProps)(TodoApp)
219219
```
220220

221+
##### Inject `todos` and specific action creators (`addTodo` and `deleteTodo`) with shorthand syntax
222+
```js
223+
import { addTodo, deleteTodo } from './actionCreators'
224+
225+
function mapStateToProps(state) {
226+
return { todos: state.todos }
227+
}
228+
229+
const mapDispatchToProps = {
230+
addTodo,
231+
deleteTodo
232+
}
233+
234+
export default connect(mapStateToProps, mapDispatchToProps)(TodoApp)
235+
```
236+
221237
##### Inject `todos`, todoActionCreators as `todoActions`, and counterActionCreators as `counterActions`
222238

223239
```js

0 commit comments

Comments
 (0)