Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
callback(tour) {
const { action, index, type } = tour;
if (this.refs.joyride) {
if (index || index === 0) {
if (tour.step && tour.step.callback && type === 'tooltip' /* && undone*/) {
let doneSteps = (new Set(this.state.doneSteps)).add(index);
tour.step.callback();
this.setState({ doneSteps });
}
}
if (action === ACTIONS.CLOSE) {
this.h.toggleTour(false);
this.setState({ doneSteps: new Set(), stepIndex: 0 });
}
if (type === EVENTS.TOUR_END) {
this.h.toggleTour(false);
this.setState({ doneSteps: new Set(), stepIndex: 0 });
} else if ([EVENTS.STEP_AFTER, EVENTS.CLOSE, EVENTS.TARGET_NOT_FOUND].includes(type)) {
// Since this is a controlled tour you'll need to update the state to advance the tour
this.setState({ stepIndex: index + (action === ACTIONS.PREV ? -1 : 1) });
}
}
}