trash-and-fire / lightweight-charts-react-wrapper

React wrapper for financial lightweight charts
Other
58 stars 5 forks source link

Maximum update depth exceeded error when using setState inside onCrosshairMove #19

Open hyperg3g opened 5 months ago

hyperg3g commented 5 months ago

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

trash-and-fire commented 5 months ago

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