why-did-you-render: wrong message when useMemo re-renders
In the following case:
const A = () => {
const obj = useMemo(() => ({
// something big
}), [a, b, c, d, e]);
return <Child obj={obj} />;
}
when the hook useMemo re-creates obj even if it’s deps deep equals, the message says A was re-rendered because if it, where in reality useMemo re-generated obj without a reason, but A is not re-rendered because of this.
About this issue
- Original URL
- State: closed
- Created 5 years ago
- Comments: 22 (7 by maintainers)
@code-guru @Hypnosphi released a fix in version v5.0.0-rc.1
this guy built a whole library around it: https://github.com/alexreardon/use-memo-one