File tree Expand file tree Collapse file tree 1 file changed +13
-5
lines changed
packages/mdx/src/mdx-client Expand file tree Collapse file tree 1 file changed +13
-5
lines changed Original file line number Diff line number Diff line change @@ -51,13 +51,21 @@ export function Slideshow({
5151 stepIndex : initialSlide ,
5252 step : editorSteps [ initialSlide ] ,
5353 } )
54- const tab = state . step
54+
55+ // Destructure these values and give them more semantic names for use below
56+ const {
57+ stepIndex : currentSlideIndex ,
58+ step : tab ,
59+ } = state ;
5560
5661 // Run any time our Slideshow state changes
5762 React . useEffect ( ( ) => {
5863 // Return our state object to the Slideshow onChange function
59- onSlideshowChange ( state ) ;
60- } , [ state ] ) ;
64+ onSlideshowChange ( {
65+ index : currentSlideIndex
66+ } ) ;
67+ // We are only calling this effect if the current slide changes.
68+ } , [ currentSlideIndex ] ) ;
6169
6270 function onTabClick ( filename : string ) {
6371 const newStep = updateEditorStep (
@@ -95,7 +103,7 @@ export function Slideshow({
95103 ) : hasPreviewSteps ? (
96104 < Preview
97105 className = "ch-slideshow-preview"
98- { ...previewChildren [ state . stepIndex ] [ "props" ] }
106+ { ...previewChildren [ currentSlideIndex ] [ "props" ] }
99107 />
100108 ) : null }
101109 </ div >
@@ -151,7 +159,7 @@ export function Slideshow({
151159
152160 { hasNotes && (
153161 < div className = "ch-slideshow-note" >
154- { stepsChildren [ state . stepIndex ] }
162+ { stepsChildren [ currentSlideIndex ] }
155163 </ div >
156164 ) }
157165 </ div >
You can’t perform that action at this time.
0 commit comments