For AI agents: the complete documentation index is available at /next/zh/llms.txt, the full documentation bundle is available at /next/zh/llms-full.txt, and this page is available as Markdown at /next/zh/api/react/Interface.Root.md.
  • 简体中文
  • @lynx-js/react / Root

    接口: Root

    The default root exported by @lynx-js/react for you to render a JSX

    属性

    registerDataProcessors()

    registerDataProcessors: (dataProcessorDefinition: DataProcessorDefinition) => void;

    Register DataProcessors. You MUST call this before root.render().

    参数

    范围类型
    dataProcessorDefinitionDataProcessorDefinition

    返回

    void

    已被弃用

    use lynx.registerDataProcessors instead

    定义于

    @lynx-js/react/runtime/lib/lynx-api.d.ts:60


    render()

    render: (jsx: ReactNode) => void;

    Use this API to pass in your JSX to render

    参数

    范围类型
    jsxReactNode

    返回

    void

    Examples

    import { root } from "@lynx-js/react"
    
    function App() {
      // Your app
      return <view>...</view>
    }
    
    root.render(<App/>);
    import { root } from "@lynx-js/react"
    
    function App() {
      // Your app
      return <view>...</view>
    }
    
    if (__MAIN_THREAD__) {
      root.render(
        <DataProvider data={DEFAULT_DATA}>
           <App/>
        </DataProvider>
      );
    } else if (__BACKGROUND__) {
      fetchData().then((data) => {
        root.render(
          <DataProvider data={data}>
             <App/>
          </DataProvider>
        ); // You can render later after your data is ready
      })
    }

    定义于

    @lynx-js/react/runtime/lib/lynx-api.d.ts:54

    除非另有说明,本项目采用知识共享署名 4.0 国际许可协议进行许可,代码示例采用 Apache License 2.0 许可协议进行许可。