Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Reset time? #47

Open
maartenvandillen opened this issue Oct 27, 2021 · 1 comment
Open

Reset time? #47

maartenvandillen opened this issue Oct 27, 2021 · 1 comment

Comments

@maartenvandillen
Copy link

Hi thank you for this component! Is there any way to reset the timer back to 00:00:00?
I've seen issue #13 where I can set the individual numbers, but a change of the <Timer time={time} time prop is not handled in a component update function. It seems that you only read props.time in the componentDidMount function.

@qxde
Copy link

qxde commented Feb 10, 2023

try to add the componentDidUpdate() function
like this at react-native-flip-timer.cjs.js ,about 625 lines

_proto.componentDidUpdate = function componentDidUpdate(prevProps) {
      var _this4 = this;
      if (prevProps.time == !this.props.time) {
        var _this$props = this.props,
          time = _this$props.time,
          play = _this$props.play;
        console.log(prevProps.time)
        var _TransformUtils$forma = TransformUtil.formatNumberToTime(0),
          hours = _TransformUtils$forma.hours,
          minutes = _TransformUtils$forma.minutes,
          seconds = _TransformUtils$forma.seconds;
        this.setState({
          hours: hours,
          minutes: minutes,
          seconds: seconds
        });
      }
    };

then try to change the state of time(different from last state to access prevProps.time == !this.props.time )
this will set time to 0

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants