mirror of
https://github.com/wavetermdev/docusaurus-og.git
synced 2026-08-05 13:46:35 -07:00
fix: render the mdx scroll button after react hydration
This commit is contained in:
@@ -1,5 +1,6 @@
|
||||
import clsx from 'clsx'
|
||||
import React, { PropsWithChildren } from 'react'
|
||||
import { useHydrated } from '../../../lib/useHydrated'
|
||||
import { useHero } from '../Hero/Hero.context'
|
||||
import { ScrollToBottom } from '../index'
|
||||
import './HeroInfo.scss'
|
||||
@@ -17,6 +18,7 @@ export const HeroInfo: React.FC<HeroInfoProps> = ({
|
||||
...props
|
||||
}) => {
|
||||
const ctx = useHero()
|
||||
const hydrated = useHydrated()
|
||||
const size = sizeProp ? sizeProp : ctx ? ctx.size : 'medium'
|
||||
|
||||
return (
|
||||
@@ -27,7 +29,7 @@ export const HeroInfo: React.FC<HeroInfoProps> = ({
|
||||
>
|
||||
{children}
|
||||
</div>
|
||||
<ScrollToBottom />
|
||||
{hydrated && <ScrollToBottom />}
|
||||
</>
|
||||
)
|
||||
}
|
||||
|
||||
+1
-3
@@ -3,7 +3,6 @@ import clsx from 'clsx'
|
||||
import React, { HTMLProps } from 'react'
|
||||
import { useWindowSize } from 'react-use'
|
||||
import { makeStyle } from '../../../lib/makeStyle'
|
||||
import { useHydrated } from '../../../lib/useHydrated'
|
||||
import { useIsMobile } from '../../../lib/useIsMobile'
|
||||
import { useScrollY } from '../../../lib/useScrollY'
|
||||
import styles from './styles.module.scss'
|
||||
@@ -14,7 +13,6 @@ export const ScrollToBottom = (
|
||||
props: TProps & HTMLProps<HTMLButtonElement>,
|
||||
): JSX.Element => {
|
||||
const { children, className, style, ...rest } = props
|
||||
const isHydrated = useHydrated()
|
||||
const scrollY = useScrollY()
|
||||
const isMobile = useIsMobile()
|
||||
const ws = useWindowSize()
|
||||
@@ -43,7 +41,7 @@ export const ScrollToBottom = (
|
||||
className={clsx(
|
||||
styles.scrollToBottom,
|
||||
className,
|
||||
(scrollY > 20 || !isHydrated) && styles.hide,
|
||||
scrollY > 20 && styles.hide,
|
||||
)}
|
||||
style={makeStyle({ ...(style ?? {}) }, { vh: ws.height / 100 + 'px' })}
|
||||
{...(rest as any)}
|
||||
|
||||
Reference in New Issue
Block a user