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({
51
51
stepIndex : initialSlide ,
52
52
step : editorSteps [ initialSlide ] ,
53
53
} )
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 ;
55
60
56
61
// Run any time our Slideshow state changes
57
62
React . useEffect ( ( ) => {
58
63
// 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 ] ) ;
61
69
62
70
function onTabClick ( filename : string ) {
63
71
const newStep = updateEditorStep (
@@ -95,7 +103,7 @@ export function Slideshow({
95
103
) : hasPreviewSteps ? (
96
104
< Preview
97
105
className = "ch-slideshow-preview"
98
- { ...previewChildren [ state . stepIndex ] [ "props" ] }
106
+ { ...previewChildren [ currentSlideIndex ] [ "props" ] }
99
107
/>
100
108
) : null }
101
109
</ div >
@@ -151,7 +159,7 @@ export function Slideshow({
151
159
152
160
{ hasNotes && (
153
161
< div className = "ch-slideshow-note" >
154
- { stepsChildren [ state . stepIndex ] }
162
+ { stepsChildren [ currentSlideIndex ] }
155
163
</ div >
156
164
) }
157
165
</ div >
You can’t perform that action at this time.
0 commit comments