Skip to content

Commit

Permalink
chore: more robust handling of finding previous step
Browse files Browse the repository at this point in the history
  • Loading branch information
jerelmiller committed Oct 14, 2020
1 parent 1095bd1 commit ed33c14
Showing 1 changed file with 7 additions and 4 deletions.
11 changes: 7 additions & 4 deletions src/components/Tutorial.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,10 +25,13 @@ const Tutorial = ({ children }) => {
];
}

const previousStep =
idx === 0
? new Map(initialState)
: new Map(steps[idx - 1].props.step || initialState);
const previousStep = new Map(
steps
.slice(0, idx)
.map((element) => element.props.step)
.reverse()
.find(Boolean) || initialState
);

const { fileName, code, language } = parseCodeBlockProps(codeBlock);

Expand Down

0 comments on commit ed33c14

Please sign in to comment.