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/reactlynx-testing-library/Interface.RenderHookOptions.md.
Lynx
  • 简体中文
  • reactlynx-testing-library / RenderHookOptions

    RenderHookOptions<Props>

    The options for renderHook

    类型参数

    类型参数
    Props

    属性

    initialProps?

    optional initialProps: Props;

    The argument passed to the renderHook callback. Can be useful if you plan to use the rerender utility to change the values passed to your hook.

    定义于

    index.d.ts:1347


    wrapper?

    optional wrapper: JSXElementConstructor<object>;

    Pass a React Component as the wrapper option to have it rendered around the inner element. This is most useful for creating reusable custom render functions for common data providers. See setup for examples.

    类型声明

    children
    children: ReactNode;

    示例

    import { renderHook } from '@lynx-js/react/testing-library'
    import { ThemeProvider } from 'my-ui-lib'
    import { TranslationProvider } from 'my-i18n-lib'
    import defaultStrings from 'i18n/en-x-default'
    
    const AllTheProviders = ({children}) => {
      return (
        <ThemeProvider theme="light">
          <TranslationProvider messages={defaultStrings}>
            {children}
          </TranslationProvider>
        </ThemeProvider>
      )
    }
    
    const customRenderHook = (ui, options) =>
      renderHook(ui, { wrapper: AllTheProviders, ...options })
    
    // re-export everything
    export * from '@lynx-js/react/testing-library'
    
    // override renderHook method
    export { customRender as renderHook }

    定义于

    index.d.ts:1380

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