mirror of
https://github.com/facebook/react.git
synced 2025-11-01 09:12:30 +00:00
6e038f96990d18d06ca9480b2c16c15437de51cf
The approach i initially took to validating function expressions was to try to extend the mutable range if they are called during render, and then use the mutable range of a function to determine if it's called during render later. However there are cases where the range can be extended for other reasons, as @poteto discovered, so we can't rely on the range extension. We've had several of our validations completely off as a result of this. In this PR i'm re-enabling @poteto's ValidateNoSetStateInRender pass by default, but making the function expression checking use a separate compiler flag. This means we'll have some false negatives, but should guarantee that we avoid false positives. This means we can definitely catch things like: ``` const [state, setState] = useState(false); setState(true); ``` Which we would have allowed by default before.
Description
Languages
JavaScript
67.1%
TypeScript
29.4%
HTML
1.5%
CSS
1.1%
C++
0.6%
Other
0.2%