EEGEdu icon indicating copy to clipboard operation
EEGEdu copied to clipboard

The sliders last value is not used to update the charts, but the value before that, callback race problem

Open kylemath opened this issue 5 years ago • 0 comments

Describe the bug When adjusting sliders, the data shows the second to last values selected, instead of the last

To Reproduce Go to raw data, adjust sliders,

Expected behavior should update charts to newest possible settings

I think it is a race problem where the callback is not complete at setting the new settings before the pipe gets recreated with the old settings, similar to this problem: https://stackoverflow.com/questions/30550314/react-input-range-slider-not-propagating-last-value-to-its-owner-in-chrome

  function handleIntervalRangeSliderChange(value) {
    setSettings(prevState => ({...prevState, interval: value}));
    resetPipeSetup();
  }

so resetPipeSetup() runs before setSettings is done, I tried something like this but setSettings can only have one callback:

  function handleIntervalRangeSliderChange(value) {
    setSettings(prevState => ({...prevState, interval: value}), function () {
      resetPipeSetup();
    });
  }

kylemath avatar Jan 17 '20 04:01 kylemath