Skip to content

Commit 80a54ad

Browse files
committed
docs: update README with goToStep
1 parent 77b847c commit 80a54ad

File tree

1 file changed

+5
-3
lines changed

1 file changed

+5
-3
lines changed

README.md

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -120,8 +120,9 @@ Provide an optional `stepIndex` to either `nextStep` or `previousStep` to overwr
120120

121121
| name | type | description |
122122
| ------------ | -------------------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------- |
123-
| nextStep | (stepIndex?: number) => Promise<void> | Go to the next step. Overwrite the default behaviour by providing a step index |
124-
| previousStep | (stepIndex?: number) => void | Go to the previous step. Overwrite the default behaviour by providing a step index |
123+
| nextStep | () => Promise<void> | Go to the next step |
124+
| previousStep | () => void | Go to the previous step index |
125+
| goToStep | (stepIndex: number) => void | Go to the given step index |
125126
| handleStep | (handler: Handler) => void | Attach a callback that will be called when calling `nextStep`. `handler` can be either sync or async |
126127
| isLoading | boolean | \* Will reflect the handler promise state: will be `true` if the handler promise is pending and `false` when the handler is either fulfilled or rejected |
127128
| activeStep | number | The current active step of the wizard |
@@ -152,6 +153,7 @@ const Step1 = () => {
152153
activeStep,
153154
previousStep,
154155
nextStep,
156+
goToStep,
155157
handleStep,
156158
} = useWizard();
157159

@@ -166,13 +168,13 @@ const Step1 = () => {
166168
{isLoading && <p>loading...</p>}
167169
<button onClick={() => previousStep()}>Previous</button>
168170
<button onClick={() => nextStep()}>Next</button>
171+
<button onClick={() => goToStep(2)}>Go to the last step</button>
169172
<div>
170173
Has next step: {!isLastStep ? '' : ''}
171174
<br />
172175
Has previous step : {!isFirstStep ? '' : ''}
173176
</div>
174177
Active step: {activeStep + 1} <br />
175-
</>
176178
);
177179
};
178180
```

0 commit comments

Comments
 (0)