visx icon indicating copy to clipboard operation
visx copied to clipboard

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

Open rarenal opened this issue 2 years ago • 1 comments

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

https://user-images.githubusercontent.com/11938799/161697698-adb7593a-16f5-4cf8-a89c-8918a50995fe.mov

rarenal avatar Apr 05 '22 07:04 rarenal

I'm experiencing the same issue

gidesan avatar May 23 '22 09:05 gidesan

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

lancefaler avatar Feb 03 '23 20:02 lancefaler

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

s-kethiri avatar Mar 30 '23 15:03 s-kethiri

Also facing the same issue.

Wondering if anyone has got a solution.

rafaelsmgomes avatar May 17 '23 01:05 rafaelsmgomes

Same here, anyone managed to fix it?

GerardGarcia avatar Aug 08 '23 12:08 GerardGarcia

Same issue here, any update about it?

VGamezz19 avatar Nov 02 '23 11:11 VGamezz19

Thanks to @dsdevgit for the fix here! https://github.com/airbnb/visx/pull/1778

williaster avatar Dec 15 '23 21:12 williaster