catc/react-timekeeper

Error on component unmount

ingava opened this issue · 3 comments

Hi, @catc,

I'm getting this error when the component mounts/unmounts:
screen shot 2017-12-13 at 10 18 23
screen shot 2017-12-13 at 10 19 20
I'm worried that if we cannot remove event listener it will cause memory leak.

This is how I am using the component:

import TimeKeeper from 'react-timekeeper';
...
const timerConfig = {
  FONT_FAMILY: '"proxima-soft", sans-serif',
};
...
class TimeSelection extends Component {
  state = {
    time: null,
  };

  handleChange = (newTime) => {
    this.setState({ time: newTime.formatted });
  };
...
render () {
const { time } = this.state;
    return (
     ...
          <TimeKeeper
            time={time}
            config={timerConfig}
            switchToMinuteOnHourSelect
            onChange={this.handleChange}
          />
    )
  }
}

Am I missing something?

Hey @ingava,

From what I can see is that TimeKeeper caught mousedown event, then unmounted and then mouseup was triggered thus creating the undefined error because the component was no longer there. Should the TimeKeeper component disappear when clicked in your design? It's hard to say what's going on without seeing the rest of your render function.

catc commented

@ingava can you reproduce the issue in a react sandbox/jsfiddle?

catc commented

Closing due to inactivity but can re-open issue if it's still a problem.