Skip to content

Feature: Add additional Step Handlers useWizard #197

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

Open
wants to merge 3 commits into
base: main
Choose a base branch
from

Conversation

mbtz
Copy link

@mbtz mbtz commented Oct 16, 2024

Description

Hi!
The company I work with had a case where we needed to attach some effects whenever we changed the step away from the current one, calling a function and doing some API calls. We couldn't easily use the onStepChange prop in the Wizard component as the definition of the function needed data for the particular Step-component it was in. handleStep was not sufficient, as we needed to also call this function when navigating back (or go directly to another step).

This PR adds additional step handlers to the useWizard hook, allowing more control over the wizard's steps when calling previousStep and goToStep. The methodology has in large part been copied from handleStep to be consistent,

Key Changes

Added new step handlers to manage wizard logic.
Updated documentation to reflect new feature.
Updated test to reflect the async nature of the previousStep and gotToStep changes.

mbtz added 3 commits October 16, 2024 15:55
This allows users to attach callbacks to be called when navigating backwards,
and jumping in the step hiearchy. This takes the handler for next step as
inspiration for the other triggers, encapsulating them in the same async call methods.

These differ from usig the onStepChange method, and allows for attaching different behaviour
inside step components instead of higher up in a component hiearachy.
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

Successfully merging this pull request may close these issues.

1 participant