Skip to content

Control the tour in other component #870

Closed Answered by gilbarbara
philippenunes asked this question in Q&A
Discussion options

You must be logged in to vote

Hey @philippenunes

You can set up a controlled tour using the stepIndex prop and use the disableBeacon prop in every step.

You'll need to update the stepIndex yourself in the callback.

import { CallBackProps, EVENTS, STATUS } from 'react-joyride';

const handleJoyrideCallback = (data: CallBackProps) => {
  const { action, index, status, type } = data;

  if (([STATUS.FINISHED, STATUS.SKIPPED] as string[]).includes(status)) {
    // Need to set our running state to false, so we can restart if we click start again.
    setState({ run: false, stepIndex: 0 });
  } else if (([EVENTS.STEP_AFTER, EVENTS.TARGET_NOT_FOUND] as string[]).includes(type)) {
    const nextStepIndex = index + (action === 

Replies: 2 comments

Comment options

You must be logged in to vote
0 replies
Answer selected by gilbarbara
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants