Skip to content

Commit

Permalink
wrap a single child into an array for getSteps
Browse files Browse the repository at this point in the history
  • Loading branch information
resolritter committed Sep 5, 2020
1 parent 17e80df commit b6f5c87
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 2 deletions.
2 changes: 1 addition & 1 deletion src/index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ export type StepWizardProps = Partial<{
exitLeft?: string
}

children: JSX.Element[]
children: JSX.Element | JSX.Element[]
}>

export type StepWizardChildProps<T extends Record<string, any> = {}> = {
Expand Down
4 changes: 3 additions & 1 deletion src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,9 @@ export default class StepWizard extends PureComponent {
return this.getSteps().length;
}

getSteps = () => this.props.children.filter(el => el);
getSteps = () => (
Array.isArray(this.props.children) ? this.props.children : [this.props.children]
).filter(el => el);

/** Go to first step */
firstStep = () => this.goToStep(1)
Expand Down

0 comments on commit b6f5c87

Please sign in to comment.