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/Function.memo.md.
  • 简体中文
  • @lynx-js/react / memo

    函数: memo()

    memo(Component, propsAreEqual)

    function memo<P>(Component: FunctionComponent<P>, propsAreEqual?: (prevProps: Readonly<P>, nextProps: Readonly<P>) => boolean): NamedExoticComponent<P>

    Lets you skip re-rendering a component when its props are unchanged.

    类型参数

    类型参数
    P extends object

    参数

    范围类型描述
    ComponentFunctionComponent<P>The component to memoize.
    propsAreEqual?(prevProps: Readonly<P>, nextProps: Readonly<P>) => booleanA function that will be used to determine if the props have changed.

    返回

    NamedExoticComponent<P>

    参阅

    React Docs

    示例

    import { memo } from 'react';
    
    const SomeComponent = memo(function SomeComponent(props: { foo: string }) {
      // ...
    });

    定义于

    .pnpm/@types+react@18.3.28/node_modules/@types/react/ts5.0/index.d.ts:1775

    memo(Component, propsAreEqual)

    function memo<T>(Component: T, propsAreEqual?: (prevProps: Readonly<ComponentProps<T>>, nextProps: Readonly<ComponentProps<T>>) => boolean): MemoExoticComponent<T>

    类型参数

    类型参数
    T extends ComponentType<any>

    参数

    范围类型
    ComponentT
    propsAreEqual?(prevProps: Readonly<ComponentProps<T>>, nextProps: Readonly<ComponentProps<T>>) => boolean

    返回

    MemoExoticComponent<T>

    定义于

    .pnpm/@types+react@18.3.28/node_modules/@types/react/ts5.0/index.d.ts:1779

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