Skip to content

Commit 14b2f17

Browse files
authored
Merge pull request #24 from mikestopcontinues/patch-1
Enable `startIndex` prop
2 parents 7991957 + 9ef73b6 commit 14b2f17

File tree

2 files changed

+13
-2
lines changed

2 files changed

+13
-2
lines changed

src/wizard.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,8 @@ import { Handler, WizardProps } from './types';
55
import WizardContext from './wizardContext';
66

77
const Wizard: React.FC<WizardProps> = React.memo(
8-
({ header, footer, children }) => {
9-
const [activeStep, setActiveStep] = React.useState(0);
8+
({ header, footer, children, startIndex = 0 }) => {
9+
const [activeStep, setActiveStep] = React.useState(startIndex);
1010
const [isLoading, setIsLoading] = React.useState(false);
1111
const hasNextStep = React.useRef(true);
1212
const hasPreviousStep = React.useRef(false);

test/wizard.test.tsx

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,17 @@ describe('Wizard', () => {
3737
expect(queryByText('step 2')).not.toBeInTheDocument();
3838
});
3939

40+
test('should render second step with passed `startIndex`', () => {
41+
const { queryByText } = render(
42+
<Wizard startIndex={1}>
43+
<p>step 1</p>
44+
<p>step 2</p>
45+
</Wizard>,
46+
);
47+
48+
expect(queryByText('step 2')).toBeInTheDocument();
49+
});
50+
4051
test('should render header', () => {
4152
const { queryByText } = render(ComponentWithHeader);
4253

0 commit comments

Comments
 (0)