File tree Expand file tree Collapse file tree 1 file changed +16
-3
lines changed
Expand file tree Collapse file tree 1 file changed +16
-3
lines changed Original file line number Diff line number Diff line change @@ -11,18 +11,29 @@ export default withDeck(
1111 deck : PropTypes . object . isRequired ,
1212 }
1313
14+ static getDerivedStateFromProps ( props ) {
15+ const { deck } = props
16+ if ( ! deck . active ) return null
17+ return {
18+ step : deck . step ,
19+ }
20+ }
21+
1422 constructor ( props ) {
1523 super ( props )
1624 const { update, index } = props . deck
1725 const steps = React . Children . toArray ( props . children ) . length
26+ this . state = {
27+ step : 0 ,
28+ }
1829 update ( setSteps ( index , steps ) )
1930 }
2031
2132 render ( ) {
22- const children = React . Children . toArray ( this . props . children ) . map (
23- child => ( typeof child === 'string' ? < div > { child } </ div > : child )
33+ const children = React . Children . toArray ( this . props . children ) . map ( child =>
34+ typeof child === 'string' ? < div > { child } </ div > : child
2435 )
25- const { step , mode } = this . props . deck
36+ const { mode } = this . props . deck
2637
2738 if ( mode === modes . grid ) {
2839 return children
@@ -35,6 +46,8 @@ export default withDeck(
3546 return children
3647 }
3748
49+ const { step } = this . state
50+
3851 return (
3952 < React . Fragment >
4053 { children . map ( ( child , i ) =>
You can’t perform that action at this time.
0 commit comments