Description
React version: 16.13.1 and next
Steps To Reproduce
- Re-render a component where an effect wasn't run because dependencies didn't change
- Receive missing act warning
Link to code example: https://codesandbox.io/s/missing-act-on-every-effect-ldy3b?file=/src/index.test.js
The current behavior
React creates warnings for each call of React.useEffect regardless of whether an effect was actually scheduled i.e. the effect was run.
The expected behavior
If it is impossible for an effect to be run I shouldn't have to wrap it in act. Changing the behavior would help identifying what effects were unexpectedly scheduled. Right now we receive warnings for effects that are unrelated to a specific update.
I consider the current warning misleading and unnecessary because the documentation talks about "all updates related to these “units”" which is not the case here in my opinion. The act warning says "When testing, code that causes React state updates should be wrapped into act(...):" which also doesn't apply here: The code in question could not cause a state update from an effect.