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

    Type Parameters

    • P extends object

    Parameters

    • Component: FunctionComponent<P>

      The component to memoize.

    • Optional propsAreEqual: ((prevProps, nextProps) => boolean)

      A function that will be used to determine if the props have changed.

        • (prevProps, nextProps): boolean
        • Parameters

          • prevProps: Readonly<P>
          • nextProps: Readonly<P>

          Returns boolean

    Returns NamedExoticComponent<P>

    See

    React Docs

    Example

    import { memo } from 'react';

    const SomeComponent = memo(function SomeComponent(props: { foo: string }) {
    // ...
    });
  • Type Parameters

    Parameters

    • Component: T
    • Optional propsAreEqual: ((prevProps, nextProps) => boolean)

    Returns MemoExoticComponent<T>