visx
visx copied to clipboard
Brush: "An update was scheduled from inside an update function" warning when using "resetOnEnd"
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.
- Open CodeSandbox console.
- Create a new brush area by dragging
- 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
I'm experiencing the same issue
I also am seeing this same error. Any insight as to the cause/solution?
I am also facing the same issue. Any updates on this?
Also facing the same issue.
Wondering if anyone has got a solution.
Same here, anyone managed to fix it?
Same issue here, any update about it?
Thanks to @dsdevgit for the fix here! https://github.com/airbnb/visx/pull/1778