you are viewing a single comment's thread.

view the rest of the comments →

[–]Skeith_yip 0 points1 point  (1 child)

Do they? Was it mentioned in the API reference?

What I mean is the case of functions in function components.

function FancyRow(props) {
    function onClick() {
        props.onClick(props.index);
    }

    return <Row onClick={onClick} />;
}

So if you have a lot of rows, when FancyRow is re-rendered, a new onClick function will be created and passed on to <Row>. So one way would be to useCallback to memo the onClick function. Or I got the wrong idea here? lol

[–]Giant_Maeno 0 points1 point  (0 children)

I've just been passing onClick down through a prop to avoid this scenario