Severity: AnalysisErrorSeverity.ERROR
Maturity: stable
Since 1.0.0
The ReactJS defaultProps
and propTypes
getters and getDerivedStateFromProps
lifecycle methods are considered static
.
As opposed to being called on each component instance, these lifecycle methods are called on a special, unmounted singleton of the component. As a result, it's impossible to access fields or other information specific to the "current" component instance, and doing so an cause unexpected behavior and runtime errors.
The only exceptions are the following instance members:
newProps
newState
typedPropsFactory
typedPropsFactoryJs
typedStateFactory
typedStateFactoryJs
keyForProp