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

onDone callback #500

Open
welljs opened this issue Jun 7, 2024 · 1 comment
Open

onDone callback #500

welljs opened this issue Jun 7, 2024 · 1 comment

Comments

@welljs
Copy link

welljs commented Jun 7, 2024

Version 1.3 released, but it's still not clear how to find out if the user pressed Done or not. I found many closed questions without answers, with references to documentation that says nothing about this.
Can you please give an example before closing this question?

@welljs
Copy link
Author

welljs commented Jun 7, 2024

Only after reading the code of library, I understood how to solve my problem. Here is my solution in react for next generations of seekers

  let nextClickHandler = useCallback(() => {
    //driverObj.hasNextStep() - this is what you need
    if (!driverObj.hasNextStep() && typeof onDoneClick === 'function') {
      //onDoneClick is just an optional prop of my component
      onDoneClick();
    }
    //required function call, otherwise it won't move forward
    driverObj.moveNext();
  }, [onDoneClick]);

  const driverObj = useMemo(() => {
    return driver({
      showProgress: true,
      steps,
      animate: true,
      onNextClick: nextClickHandler // assigning callback function
    });
  }, [steps, nextClickHandler]);

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

1 participant