发布于 2022-06-22 09:49:25
组件需要包装在来自ClientOnly
的remix-utils
组件中。这样,组件将只呈现在客户端上,而不会被服务器呈现.
// components/chart.jsx
import * as ReactFS from 'fusionchart'
export default function Chart() {
// this component will only render on the client
// and will not be server rendered
return (
{/* fusion chart components */}
)
}
// routes/index.tsx
import {ClientOnly} from 'remix-utils'
import Chart from '~/components/chart'
export default function() {
return (
<ClientOnly fallback={<LoadingSkeleton />}
{() => <Chart />}
</ClientOnly>
)
}
https://stackoverflow.com/questions/72712859
复制相似问题