Skip to content

Commit

Permalink
Formatted the new code blocks
Browse files Browse the repository at this point in the history
  • Loading branch information
timdorr authored Aug 27, 2019
1 parent 64b06ae commit 376d401
Showing 1 changed file with 8 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -151,26 +151,23 @@ If your `mapDispatchToProps` function is declared as taking two parameters, it w

This means, instead of re-binding new `props` to action dispatchers upon component re-rendering, you may do so when your component's `props` change.


**Binds on component re-rendering**

```js
render(){
return(
<button onClick={() => this.props.toggleTodo(this.props.todoId)} />
);
render() {
return <button onClick={() => this.props.toggleTodo(this.props.todoId)} />
}

const mapDispatchToProps = (dispatch) => {
toggleTodo: (todoId) => dispatch(toggleTodo(todoId))
const mapDispatchToProps = dispatch => {
toggleTodo: todoId => dispatch(toggleTodo(todoId))
}
```

**Binds on `props` change**

```js
render(){
return(
<button onClick={() => this.props.toggleTodo()} />
);
render() {
return <button onClick={() => this.props.toggleTodo()} />
}

const mapDispatchToProps = (dispatch, ownProps) => {
Expand Down

0 comments on commit 376d401

Please sign in to comment.