File tree Expand file tree Collapse file tree 3 files changed +20
-1
lines changed
src/semmle/javascript/frameworks
test/query-tests/React/UnusedOrUndefinedStateProperty Expand file tree Collapse file tree 3 files changed +20
-1
lines changed Original file line number Diff line number Diff line change 22
33## General improvements
44
5+ * Support for the following frameworks and libraries has been improved:
6+ - [ react] ( https://www.npmjs.com/package/react )
57
68## New queries
79
Original file line number Diff line number Diff line change @@ -136,7 +136,12 @@ abstract class ReactComponent extends ASTNode {
136136 result = arg0
137137 )
138138 or
139- result .flowsToExpr ( getStaticMethod ( "getDerivedStateFromProps" ) .getAReturnedExpr ( ) )
139+ exists ( string staticMember |
140+ staticMember = "getDerivedStateFromProps" or
141+ staticMember = "getDerivedStateFromError"
142+ |
143+ result .flowsToExpr ( getStaticMethod ( staticMember ) .getAReturnedExpr ( ) )
144+ )
140145 or
141146 // shouldComponentUpdate: (nextProps, nextState)
142147 result = DataFlow:: parameterNode ( getInstanceMethod ( "shouldComponentUpdate" ) .getParameter ( 1 ) )
Original file line number Diff line number Diff line change 1+ import React from "react"
2+
3+ class C extends React . Component {
4+ static getDerivedStateFromError ( error ) {
5+ return { error }
6+ }
7+
8+ render ( ) {
9+ this . state . error ;
10+ }
11+ }
12+
You can’t perform that action at this time.
0 commit comments