Skip to content

[Basic] Provide some docs on memo #719

@silverwind

Description

@silverwind

What cheatsheet is this about? (if applicable)

Basic cheatsheet

What's your issue or idea?

Some docs on memo would be useful.

For example it took me a while to understand that such a combination of memo and forwardRef is wrong (the resulting type would not include ref):

const Div = memo<Props>(forwardRef<HTMLDivElement, Props>(function Div(props, ref) => {
  return <div ref={ref}/>;
}));

The correct way is to omit <Props> on memo if there is forwardRef inside it, so my suggestions are:

const Div = memo(forwardRef<HTMLDivElement, Props>(function Div((props, ref) => {
  return <div ref={ref}/>;
}));
const Div = memo<Props>(function Div(props => {
  return <div/>;
});

Metadata

Metadata

Assignees

No one assigned

    Labels

    BASICBasic Cheatsheet

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions