Skip to content
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

Brush: "An update was scheduled from inside an update function" warning when using "resetOnEnd" #1465

Closed
rarenal opened this issue Apr 5, 2022 · 7 comments

Comments

@rarenal
Copy link

rarenal commented Apr 5, 2022

Problem

When using resetOnEnd in a Brush and after there's a brush end event, the following React warning is thrown
Warning: An update (setState, replaceState, or forceUpdate) was scheduled from inside an update function. Update functions should be pure, with zero side-effects. Consider using componentDidUpdate or a callback.

This error is also reproducible if instead of using "resetOnEnd" the brush reference is used inside an "onBrushEnd" to call directly the "reset()" function

const handleBrushEnd = () => {
    if (brushRef?.current) {
      brushRef.current.reset();
    }
  };

Steps to reproduce

I created this demo which basically consists of the Brush example with the "resetOnEnd" attribute.

  1. Open CodeSandbox console.
  2. Create a new brush area by dragging
  3. On the brush end, check how the warning appears in the console.

Attachments

Screen.Recording.2022-04-05.at.09.04.23.mov
@gidesan
Copy link

gidesan commented May 23, 2022

I'm experiencing the same issue

@lancefaler
Copy link

I also am seeing this same error. Any insight as to the cause/solution?

@s-kethiri
Copy link

I am also facing the same issue. Any updates on this?

@rafaelsmgomes
Copy link

Also facing the same issue.

Wondering if anyone has got a solution.

@GerardGarcia
Copy link

GerardGarcia commented Aug 8, 2023

Same here, anyone managed to fix it?

@VGamezz19
Copy link

Same issue here, any update about it?

@williaster
Copy link
Collaborator

Thanks to @dsdevgit for the fix here! #1778

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

8 participants