Query module InconsistentStateUpdate

name
Potentially inconsistent state update
description
Updating the state of a component based on the current value of ‘this.state’ or ‘this.props’ may lead to inconsistent component state.
kind
problem
problem.severity
warning
id
js/react/inconsistent-state-update
tags
reliability frameworks/react
precision
very-high

Imports

React

Provides classes for working with React and Preact code.

Predicates

getAStateUpdate

Gets a property write through setState for state property name of c.

getAUniqueStateUpdate

Gets a property write through setState for a state property of c that is only written at this property write.

getAnOutermostUnsafeAccess

Gets at unsafe property access that is not the base of another unsafe property access.

getAnUnsafeAccess

Gets an unsafe property access, that is, an expression that reads (a property of) this.state or this.prop on component c.

isAStateUpdateFromSelf

Holds for “self dependent” component state updates. E.g. this.setState({toggled: !this.state.toggled}).