Skip to content

Commit 862dfcc

Browse files
committed
fix: update state
1 parent d7a6e9e commit 862dfcc

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

src/reworm.tsx

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -60,8 +60,9 @@ export class Provider extends Component {
6060
}
6161

6262
private handleUpdate = (id: string, next: any) => {
63-
const nextState = typeof next === 'function' ? next(this.state) : next
64-
this.setState({ [id]: nextState })
63+
this.setState((prevState: any) => ({
64+
[id]: typeof next === 'function' ? next(prevState[id]) : next,
65+
}))
6566
}
6667
}
6768

0 commit comments

Comments
 (0)