🚧 Rspress 2.0 文档还在开发中
close

Root eject-only

Warning

该组件是 eject-only 组件,专门为 wrap/eject 设计,不建议在 MDX 文件中直接使用

Root 是整个应用的包装组件,包裹所有内容(包括 Layout 和全局 UI 组件)。

它的源代码如下:

Root.tsx
export function Root({ children }: RootProps) {
  return <>{children}</>;
}

用法

通过 eject 来使用它,用于包裹自定义的 Provider:

theme/components/Root/index.tsx
import type { RootProps } from '@rspress/core/theme';

export function Root({ children }: RootProps) {
  return <YourProvider>{children}</YourProvider>;
}

Props

children

  • 类型: ReactNode
  • 必填:

需要渲染的子元素,包含整个应用的内容。