JS: model React's getDerivedStateFromError

This commit is contained in:
Esben Sparre Andreasen
2019-11-20 12:57:35 +01:00
parent 53576a4781
commit 03c83c9c9d
2 changed files with 18 additions and 1 deletions

View File

@@ -136,7 +136,12 @@ abstract class ReactComponent extends ASTNode {
result = arg0
)
or
result.flowsToExpr(getStaticMethod("getDerivedStateFromProps").getAReturnedExpr())
exists(string staticMember |
staticMember = "getDerivedStateFromProps" or
staticMember = "getDerivedStateFromError"
|
result.flowsToExpr(getStaticMethod(staticMember).getAReturnedExpr())
)
or
// shouldComponentUpdate: (nextProps, nextState)
result = DataFlow::parameterNode(getInstanceMethod("shouldComponentUpdate").getParameter(1))