import { useEffect, useContext, useMemo } from 'react';
import { TourContext } from './context';
export const useTour = ({
  isShowTour = false,
  tourId = ''
}) => {
  const {
    setTourId,
    setShowTour,
    setStepId,
    stepId,
    ...rest
  } = useContext(TourContext);
  useEffect(() => {
    setShowTour(isShowTour);
    setTourId(tourId);
    return () => {
      setShowTour(false);
      setTourId('');
      setStepId(0);
    };
  }, [isShowTour, tourId]);
  return useMemo(() => ({
    setShowTour,
    setTourId,
    setStepId,
    stepId,
    ...rest
  }), [tourId, stepId]);
};