mirror of
https://github.com/github/codeql.git
synced 2025-12-17 01:03:14 +01:00
JS: model React's getDerivedStateFromError
This commit is contained in:
@@ -136,7 +136,12 @@ abstract class ReactComponent extends ASTNode {
|
|||||||
result = arg0
|
result = arg0
|
||||||
)
|
)
|
||||||
or
|
or
|
||||||
result.flowsToExpr(getStaticMethod("getDerivedStateFromProps").getAReturnedExpr())
|
exists(string staticMember |
|
||||||
|
staticMember = "getDerivedStateFromProps" or
|
||||||
|
staticMember = "getDerivedStateFromError"
|
||||||
|
|
|
||||||
|
result.flowsToExpr(getStaticMethod(staticMember).getAReturnedExpr())
|
||||||
|
)
|
||||||
or
|
or
|
||||||
// shouldComponentUpdate: (nextProps, nextState)
|
// shouldComponentUpdate: (nextProps, nextState)
|
||||||
result = DataFlow::parameterNode(getInstanceMethod("shouldComponentUpdate").getParameter(1))
|
result = DataFlow::parameterNode(getInstanceMethod("shouldComponentUpdate").getParameter(1))
|
||||||
|
|||||||
@@ -0,0 +1,12 @@
|
|||||||
|
import React from "react"
|
||||||
|
|
||||||
|
class C extends React.Component {
|
||||||
|
static getDerivedStateFromError(error) {
|
||||||
|
return { error }
|
||||||
|
}
|
||||||
|
|
||||||
|
render() {
|
||||||
|
this.state.error;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
Reference in New Issue
Block a user