I'm trying to update the clock in the root component. The general view of the application is:
<App> <Input/> {timer} </App> Initially, the default city is loaded from the store, after that I set the initial time value (setTime ()):
componentWillMount() { const { setTime, timeOffset } = this.props; setTime(timeOffset); }; Then, respectively, I launch setInterval, the timer for the current city is running, the clock is working:
componentDidMount() { const { setTime, timeOffset } = this.props; this.timer = setInterval(() => { setTime(timeOffset); }, 1000); } After in the submission I get the coordinates of the newly entered city, I get a fresh time zone - everything is asynchronous, the props change with a delay by themselves. How now to restart the clock / timer by setTime () with the new value of timeOffset, which exactly comes in app.props? Tried to restart the timer deferred, tried out the options that the functions of the life cycle provide. Either overlooked something - did not finish reading, or do you completely need to change the logic of the timer?