Skip to content

Commit

Permalink
fix: update state
Browse files Browse the repository at this point in the history
  • Loading branch information
pedronauck committed Oct 6, 2018
1 parent d7a6e9e commit 862dfcc
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions src/reworm.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -60,8 +60,9 @@ export class Provider extends Component {
}

private handleUpdate = (id: string, next: any) => {
const nextState = typeof next === 'function' ? next(this.state) : next
this.setState({ [id]: nextState })
this.setState((prevState: any) => ({
[id]: typeof next === 'function' ? next(prevState[id]) : next,
}))
}
}

Expand Down

0 comments on commit 862dfcc

Please sign in to comment.