From cadee91b7cc8815fba2d48ad08ed1919b544e06d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9D=A8=E4=BF=8A=E5=AE=81?= Date: Thu, 23 Jul 2020 12:25:33 +0800 Subject: [PATCH] [Docs] `no-access-state-in-setstate`: fix example --- docs/rules/no-access-state-in-setstate.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/docs/rules/no-access-state-in-setstate.md b/docs/rules/no-access-state-in-setstate.md index bf29f53d04..8a86824467 100644 --- a/docs/rules/no-access-state-in-setstate.md +++ b/docs/rules/no-access-state-in-setstate.md @@ -15,8 +15,8 @@ If two `setState` operations are grouped together in a batch, they both evaluate the old state. Given that `state.value` is 1: ```javascript -setState({value: this.state.value + 1}) // 2 -setState({value: this.state.value + 1}) // 2, not 3 +this.setState({value: this.state.value + 1}) // 2 +this.setState({value: this.state.value + 1}) // 2, not 3 ``` This can be avoided with using callbacks which takes the previous state