Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Basic] Provide some docs on memo #719

Open
silverwind opened this issue Jun 26, 2024 · 1 comment
Open

[Basic] Provide some docs on memo #719

silverwind opened this issue Jun 26, 2024 · 1 comment
Labels
BASIC Basic Cheatsheet

Comments

@silverwind
Copy link

silverwind commented Jun 26, 2024

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/>;
});
@silverwind silverwind added the BASIC Basic Cheatsheet label Jun 26, 2024
@silverwind silverwind changed the title [Basic] ISSUE_TITLE_HERE [Basic] Provide some docs on memo Jun 26, 2024
@filiptammergard
Copy link
Collaborator

Sounds like it could be useful. Feel free to contribute!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
BASIC Basic Cheatsheet
Projects
None yet
Development

No branches or pull requests

2 participants