use-inline-memo icon indicating copy to clipboard operation
use-inline-memo copied to clipboard

Question: Can this library be used to memoize components inline?

Open Jexah opened this issue 3 years ago • 0 comments

Heya, nice project!

Just wanted to check if and how this library can be used to memoize components inline, e.g.:

const Row = memo((props) => {
  const { isLoadingRowAction, rowId  } = props;

  const thisLoadingRowAction = isLoadingRowAction === rowId;

  return (
    <>
      {memo.circularFadeIn(
        <Fade in={thisLoadingRowAction}>
          <CircularProgress  size={24} />
        </Fade>,
        [thisLoadingRowAction]
      )}
    </>
  );
});

It appears that the component is one render behind, e.g. the CircularProgress doesn't fade in until the render after thisLoadingRowAction is true (even if it is false on the next render).

Any advice or guidance would be appreciated :)

Edit: Just did some logging:

image

image

Appears in is true in the second log but not in the first?

Jexah avatar Feb 17 '22 10:02 Jexah