From 9d882e7a8b4403aaf0902e26098bda9b9d5f81d9 Mon Sep 17 00:00:00 2001 From: apanizo Date: Wed, 3 Oct 2018 17:35:19 +0200 Subject: [PATCH] Adding helper function to calculate penultimate and last page in Stepper --- src/components/Stepper/index.jsx | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/src/components/Stepper/index.jsx b/src/components/Stepper/index.jsx index 06c56497..882028d1 100644 --- a/src/components/Stepper/index.jsx +++ b/src/components/Stepper/index.jsx @@ -129,13 +129,16 @@ class GnoStepper extends React.PureComponent { return this.next(values) } + isLastPage = page => page === this.props.steps.length - 1 + render() { const { steps, children, classes, disabledWhenValidating = false, } = this.props const { page, values } = this.state const activePage = this.getActivePageFrom(children) - const isLastPage = page === steps.length - 1 + const lastPage = this.isLastPage(page) + const penultimate = this.isLastPage(page + 1) return ( @@ -153,7 +156,8 @@ class GnoStepper extends React.PureComponent { disabled={disabled} onPrevious={this.previous} firstPage={page === 0} - lastPage={isLastPage} + lastPage={lastPage} + penultimate={penultimate} /> )