Skip to content

Commit 26e0c5a

Browse files
authored
Merge pull request #4 from omarnyte/improve-types-with-generics
Allow stepId to be string or number
2 parents 72f5e66 + d1c9e6e commit 26e0c5a

File tree

3 files changed

+10
-11
lines changed

3 files changed

+10
-11
lines changed

README.md

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
# React Stepper
22
[![Node.js CI](https://github.com/omarnyte/react-stepper/actions/workflows/test.yml/badge.svg)](https://github.com/omarnyte/react-stepper/actions/workflows/test.yml)
3-
43
[![npm version](https://badge.fury.io/js/@xolos%2Freact-stepper.svg)](https://badge.fury.io/js/@xolos%2Freact-stepper)
54

65
A simple, flexible React step wizard hook.
@@ -44,19 +43,19 @@ export default App;
4443
## API
4544
```jsx
4645
const {
47-
currentStepId,
48-
currentStepIndex,
49-
goToNextStep,
50-
goToPreviousStep,
51-
isFirstStep,
52-
isLastStep
46+
currentStepId,
47+
currentStepIndex,
48+
goToNextStep,
49+
goToPreviousStep,
50+
isFirstStep,
51+
isLastStep
5352
} = useStepper(stepIds)
5453
```
5554
### Options
56-
* `stepIds: string[]`
55+
* `stepIds: Array<string | number>`
5756

5857
### Returns
59-
* `currentStepId: string`
58+
* `currentStepId: string | number`
6059

6160
* `currentStepIndex: number`
6261

src/index.test.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import useStepper from './index';
33

44

55
describe('useStepper', () => {
6-
const stepIds = ['first', 'second', 'third'];
6+
const stepIds = ['first', 2, 'third'];
77

88
it('begins at first step', () => {
99
const { result } = renderHook(() => useStepper(stepIds));

src/index.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import { useState } from "react";
22

3-
const useStepper = (stepIds: string[]) => {
3+
const useStepper = (stepIds: Array<string | number>) => {
44
const [currentStepIndex, setCurrentStepIndex] = useState(0);
55

66
const currentStepId = stepIds[currentStepIndex];

0 commit comments

Comments
 (0)