forked from github/codeql
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathstatePropertyWrites.js
More file actions
47 lines (38 loc) · 857 Bytes
/
statePropertyWrites.js
File metadata and controls
47 lines (38 loc) · 857 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
class Writes extends React.Component {
constructor() {
var cmp = this;
cmp.state.p1 = 42;
cmp.state.bar.foo = 42; // not a state write (but implies existence of `bar`)
var o1 = {};
o1.p2 = 42
cmp.state = o1;
var o2 = {};
o2.p3 = 42;
cmp.setState(o2);
var o3 = {};
o3.p4 = 42;
cmp.setState(() => o3);
var o4 = {};
o4.p5 = 42;
cmp.forceUpdate(() => o4);
}
getInitialState() { // not enabled for ES6 classes
var o = {};
o.p6 = 42
return o;
}
state = {
p7: 42
};
}
React.createClass({
render: function() {
return <div>Hello {this.props.name}</div>;
},
getInitialState: function() {
return {
p8: 42
};
}
});
//semmle-extractor-options: --experimental