diff --git a/src/app/components/MainContent.tsx b/src/app/components/MainContent.tsx index 122f51866b..2e3f9fce42 100644 --- a/src/app/components/MainContent.tsx +++ b/src/app/components/MainContent.tsx @@ -31,15 +31,18 @@ const ContentStyles = styled(({ textSize, ...props }) => >( - ({book, children, className, ...props}, ref) => { + ({book, children, className, ...props}, forwardedRef) => { const initialLoad = React.useRef(true); + const ref = React.useRef(null); + + React.useImperativeHandle(forwardedRef, () => ref.current as HTMLDivElement); React.useEffect( () => { if (initialLoad.current) { initialLoad.current = false; } else { - (ref as React.MutableRefObject).current?.focus(); + ref.current?.focus(); } }, [children, ref]