lightweight-charts-react-wrapper icon indicating copy to clipboard operation
lightweight-charts-react-wrapper copied to clipboard

Maximum update depth exceeded error when using setState inside onCrosshairMove

Open hyperg3g opened this issue 1 year ago • 1 comments

Any setState call inside onCrosshairMove handler function causes Maximum update depth exceeded error

Even simple examples cause this problem:

const [time, setTime] = useState<MouseEventParams['time']>(undefined)
const onCrosshairMove = (event: MouseEventParams<Time>) => setTime(event.time)

For now the only way I can handle it is by wrapping handler function with debounce with 0 delay

hyperg3g avatar Jan 26 '24 11:01 hyperg3g

I can not reproduce https://codesandbox.io/s/codesandboxer-example-forked-ns9v5r. Could you give an example with the reproduction of the problem?

trash-and-fire avatar Jan 28 '24 19:01 trash-and-fire