Skip to content

Bug: act warning misleading if an effect wasn't run #19318

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
eps1lon opened this issue Jul 11, 2020 · 3 comments
Closed

Bug: act warning misleading if an effect wasn't run #19318

eps1lon opened this issue Jul 11, 2020 · 3 comments

Comments

@eps1lon
Copy link
Collaborator

eps1lon commented Jul 11, 2020

React version: 16.13.1 and next

Steps To Reproduce

  1. Re-render a component where an effect wasn't run because dependencies didn't change
  2. 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.

@stale
Copy link

stale bot commented Oct 12, 2020

This issue has been automatically marked as stale. If this issue is still affecting you, please leave any comment (for example, "bump"), and we'll keep it open. We are sorry that we haven't been able to prioritize it yet. If you have any new additional information, please include it with your comment!

@stale stale bot added the Resolution: Stale Automatically closed due to inactivity label Oct 12, 2020
@eps1lon
Copy link
Collaborator Author

eps1lon commented Oct 12, 2020

Bump

@stale stale bot removed the Resolution: Stale Automatically closed due to inactivity label Oct 12, 2020
@eps1lon eps1lon added Component: Reconciler Type: Discussion and removed Status: Unconfirmed A potential issue that we haven't yet confirmed as a bug labels Oct 27, 2020
@eps1lon
Copy link
Collaborator Author

eps1lon commented Aug 11, 2021

Will no longer be relevant for React 18 where even a render needs to be wrapped in act. See reactwg/react-18#23 (reply in thread)

@eps1lon eps1lon closed this as completed Aug 11, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant