Skip to content

Commit 462abb6

Browse files
committed
Remove useInitialState hook
Not needed in this scenario
1 parent eb30222 commit 462abb6

File tree

2 files changed

+1
-11
lines changed

2 files changed

+1
-11
lines changed

packages/mdx/src/mdx-client/slideshow.tsx

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@ import { EditorProps, EditorStep } from "../mini-editor"
33
import { InnerCode, updateEditorStep } from "./code"
44
import { Preview, PresetConfig } from "./preview"
55
import { extractPreviewSteps } from "./steps"
6-
import { useInitialState } from "utils"
76

87
export function Slideshow({
98
children,
@@ -50,11 +49,8 @@ export function Slideshow({
5049

5150
const maxSteps = editorSteps.length - 1;
5251

53-
// This hook will prevent the slide from being changed via the start prop after render
54-
const initialSlideValue = useInitialState(start);
55-
5652
// Make sure the initial slide is not configured out of bounds
57-
const initialSlide = initialSlideValue > maxSteps ? maxSteps : initialSlideValue
53+
const initialSlide = start > maxSteps ? maxSteps : start
5854

5955
const [state, setState] = React.useState({
6056
stepIndex: initialSlide,

packages/mdx/src/utils/hooks.ts

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -5,12 +5,6 @@ export const useLayoutEffect =
55
? React.useLayoutEffect
66
: React.useEffect
77

8-
// Returns the same state, even if the state argument changes.
9-
export function useInitialState<T> (value: T | (() => T)) {
10-
const [initialState] = React.useState(value);
11-
return initialState;
12-
}
13-
148
// for debugging:
159
// export const useLayoutEffect = (
1610
// effect: any,

0 commit comments

Comments
 (0)