You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: docs/rules/no-did-update-set-state.md
+44Lines changed: 44 additions & 0 deletions
Original file line number
Diff line number
Diff line change
@@ -31,3 +31,47 @@ var Hello = React.createClass({
31
31
}
32
32
});
33
33
```
34
+
35
+
## Rule Options
36
+
37
+
```js
38
+
...
39
+
"no-did-update-set-state": [<enabled>, <mode>]
40
+
...
41
+
```
42
+
43
+
### `allow-in-func` mode
44
+
45
+
By default this rule forbids any call to `this.setState` in `componentDidUpdate`. But in certain cases you may need to perform asynchronous calls in `componentDidUpdate` that may end up with calls to `this.setState`. The `allow-in-func` mode allows you to use `this.setState` in `componentDidUpdate` as long as they are called within a function.
46
+
47
+
The following patterns are considered warnings:
48
+
49
+
```js
50
+
var Hello =React.createClass({
51
+
componentDidUpdate:function() {
52
+
this.setState({
53
+
name:this.props.name.toUpperCase()
54
+
});
55
+
},
56
+
render:function() {
57
+
return<div>Hello {this.state.name}</div>;
58
+
}
59
+
});
60
+
```
61
+
62
+
The following patterns are not considered warnings:
0 commit comments