For AI agents: the complete documentation index is available at /next/llms.txt, the full documentation bundle is available at /next/llms-full.txt, and this page is available as Markdown at /next/api/react/Functions/memo.md.
  • English
  • Function: memo()

    Call Signature

    memo<P extends object>(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.

    Type Parameters

    Type Parameter
    P extends object

    Parameters

    ParameterTypeDescription
    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.

    Returns

    NamedExoticComponent<P>

    See

    React Docs

    Example

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

    Call Signature

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

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

    Type Parameters

    Type Parameter
    T extends ComponentType<any>

    Parameters

    ParameterTypeDescription
    ComponentTThe component to memoize.
    propsAreEqual?(prevProps: Readonly<ComponentProps<T>>, nextProps: Readonly<ComponentProps<T>>) => booleanA function that will be used to determine if the props have changed.

    Returns

    MemoExoticComponent<T>

    See

    React Docs

    Example

    import { memo } from 'react';
    
    const SomeComponent = memo(function SomeComponent(props: { foo: string }) {
      // ...
    });
    Except as otherwise noted, this work is licensed under a Creative Commons Attribution 4.0 International License, and code samples are licensed under the Apache License 2.0.