Skip to content

Commit e33634a

Browse files
committed
docs: clean up readme
1 parent 4749236 commit e33634a

File tree

2 files changed

+20
-17
lines changed

2 files changed

+20
-17
lines changed

README.md

Lines changed: 19 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -72,15 +72,15 @@ const Step1 = () => {
7272

7373
### Wizard
7474

75-
`Wizard` is used to wrap your steps. Each child component will be treated as an individual step. You can set a shared `footer` and `header` that always should be in your steps. Example: pass an action button component that contain a "previous" and "next" button.
75+
`Wizard` is used to wrap your steps. Each child component will be treated as an individual step. You can pass a shared `footer` and `header` component that should always be in your steps.
7676

77-
Place the `Wizard` around it and that's it.
77+
Example: pass a footer component that contains a "previous" and "next" button to the wizard.
7878

7979
#### Props
8080

8181
| name | type | description | required | default |
8282
| ---------- | --------------- | ------------------------------------------------------------- | -------- | ------- |
83-
| startIndex | number | Start index to indicate the wizard to start at the given step || 0 |
83+
| startIndex | number | Indicate the wizard to start at the given step || 0 |
8484
| header | React.ReactNode | Header that is shown above the active step || |
8585
| footer | React.ReactNode | Footer that is shown below the active stepstep || |
8686
| children | React.ReactNode | Each child component will be treated as an individual step | ✔️ |
@@ -126,9 +126,7 @@ const App = () => {
126126

127127
### useWizard
128128

129-
Used to retrieve all methods and props bundled with the Wizard.
130-
131-
Make sure `Wizard` is wrapped around your component when calling `useWizard`.
129+
Used to retrieve all methods and properties related to your wizard. Make sure `Wizard` is wrapped around your component when calling `useWizard`.
132130

133131
**Remark** - You can't use `useWizard` in the same component where `Wizard` is used.
134132

@@ -138,9 +136,8 @@ Make sure `Wizard` is wrapped around your component when calling `useWizard`.
138136
| ----------------------------------------------------------- | ------------------------------- | ----------------------------------------------------------------------------------------------------- |
139137
| nextStep | () => Promise<void> | Go to the next step |
140138
| previousStep | () => void | Go to the previous step |
141-
| handleStep | (handler: Handler) => void | Connect a callback that will be called when calling `nextStep`. `handler` can be either sync or async |
142-
| isLoading | (props?: IntercomProps) => void | \* Will reflect the handler promise state: will be `true` if the handler promise is pending and |
143-
| \* `false` when the handler is either fulfilled or rejected |
139+
| handleStep | (handler: Handler) => void | Attach a callback that will be called when calling `nextStep`. `handler` can be either sync or async |
140+
| 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 |
144141
| activeStep | number | The current active step of the wizard |
145142
| isFirstStep | boolean | Indicate if the current step is the first step (aka no previous step) |
146143
| isLastStep | boolean | Indicate if the current step is the last step (aka no next step) |
@@ -172,7 +169,7 @@ const Step1 = () => {
172169
handleStep,
173170
} = useWizard();
174171

175-
handleStep(() => {
172+
handleStep(() => {
176173
alert('Going to step 2');
177174
});
178175

@@ -193,14 +190,14 @@ const Step1 = () => {
193190
};
194191
```
195192

196-
It's recommended to put the shared components in the `header` or `footer` in the `Wizard` to avoid duplication.
193+
It's recommended to pass the shared components to the `header` or `footer` in the `Wizard` to avoid duplication.
197194

198195
## Examples
199196
Go to [examples](https://github.com/devrnt/react-use-wiard/tree/master/examples) to check see some examples
200197

201198
## Async
202199

203-
You can connect an async step handler to a step as well. Make sure to make to either pass an async function or return a promise (async) function:
200+
You can attach an async step handler to a step as well. Make sure to make to either pass an async function or return a promise (async) function:
204201

205202
```ts
206203
const Step1 = () => {
@@ -211,6 +208,8 @@ const Step1 = () => {
211208
await fetch(...);
212209
});
213210

211+
// OR
212+
214213
// Return promise
215214
handleStep(() => {
216215
return fetch(...);
@@ -220,11 +219,15 @@ const Step1 = () => {
220219
}
221220
```
222221

223-
The `isLoading` of `useWizard` will indicate the loading state of the step when calling `nextStep`. If no errors are thrown the wizard will go to the next step, so no need to call this manually. If an error is thrown in the conencted function the wizard will just stay at the same step and will rethrow the error. (So you can try-catch in your connected function).
222+
### Errors
223+
If no errors are thrown then the wizard will go to the next step, so no need to call `nextStep` by yourself.
224+
225+
If an error is thrown in the conencted function the wizard will just stay at the same step and will rethrow the error. (So you can try-catch in your attached function).
224226

225-
If an async function is connected the `isLoading` of `useWizard` will indicate the loading state of the function.
227+
### IsLoading
228+
If an async function is attached to `handleStep` the `isLoading` property will indicate the loading state of the function. In general `isLoading` 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.
226229

227230
## Animation
228-
Since `react-use-wizard` is focused to manage the logic of a wizard doesn't mean you can't add some animation by your own. Add any animation library that you like. I highly suggest (https://www.framer.com/motion/)[framer-motion].
231+
Since `react-use-wizard` is focused to manage the logic of a wizard it doesn't mean you can't add some animation by your own. Add any animation library that you like. I highly suggest [framer-motion](https://www.framer.com/motion/) to add your animations.
229232

230-
Checkout this (https://github.com/devrnt/react-use-wizard/blob/docs/readme/example/components/animatedStep.tsx)[example] to see an animation to a step can be added.
233+
Checkout this [example](https://github.com/devrnt/react-use-wizard/blob/docs/readme/example/components/animatedStep.tsx) to see how a step can be animated with framer motion.

src/types.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ export type WizardValues = {
1515
/** Go to the previous step */
1616
previousStep: () => void;
1717
/**
18-
* Connect a callback that will be called when calling `nextStep()`
18+
* Attach a callback that will be called when calling `nextStep()`
1919
*
2020
* @param handler Can be either sync or async
2121
*

0 commit comments

Comments
 (0)