gilbarbara / react-joyride

Create guided tours in your apps
https://react-joyride.com/
MIT License
6.75k stars 524 forks source link

Restart Tour is not working in same session #442

Closed vivekh88 closed 5 years ago

vivekh88 commented 5 years ago

Expected behavior When i tried to run the tour and click finish it is working. But when i tried to run once again refreshing the page it is not starting the tour.

Actual behavior It should once again start the tour with same session.

Steps to reproduce the problem My code: static propTypes = { joyride: PropTypes.shape({ callback: PropTypes.func }) };

  `static defaultProps = {
    joyride: {}
  };

  handleClickStart = e => {  
    e.preventDefault();
    this.setState({
      run: true,
      show: false,
      stepIndex: 0,
    });
  };

  handleJoyrideCallback = data => {
    const { joyride } = this.props;
const { action, index, type } = data;

    if (type === EVENTS.TOUR_END && this.state.run) {
        console.log('tour');
        console.log(this.state.run);
      // Need to set our running state to false, so we can restart if we click start again.
      this.setState({ run: false, stepIndex: 0 });
    }
    if (typeof joyride.callback === "function") {
        joyride.callback(data);
      } else {
        console.group(type);
        console.log(data); //eslint-disable-line no-console
        console.groupEnd();
      }
    console.log(this.state.run);
  };
  `

`render() { const { run } = this.state; console.log('first', this.state.run); return (

View and manange your active subscriptions. Lorem ipsum dolor sit amet, consecteur adipiscing elit.

), placement: "left", disableBeacon: true, target: ".nav-list-2", locale: { skip: "Skip", next: "Next" }, }, { content: (

Check out our FAQs, video guides, or reach out to us in lorem ipsum dolor sit amet, consecteur adipiscing elit.

), placement: "top", }, target: ".nav-list-3", locale: { skip: "Skip", last: "Finish" }, }, ]} callback={this.handleJoyrideCallback} />` >React version >React-Joyride version >Browser name and version >Error stack (if available) *If you want to get this issue fixed quickly, make sure to send a public URL or codesandbox example.*
gilbarbara commented 5 years ago

Apparently, you are not using the stepIndex state, so you don't need it.

I'll push a fix soon.