#react memo error when creating custom component

1 messages ยท Page 1 of 1 (latest)

dapper idol
sleek creek
#

Could you share some code for your node types object?
Are you defining it inside the body of a component, like this?
If so, it should be wrapped in useMemo as the post suggests

function SomeComponent() {
   const nodeTypes = { .. }

   // ...
}
dapper idol
#

Changing to this:

const nodeTypes = useMemo(() => {
    return {
      circle: memoCircleNode,
      ResizableNodeSelected,
    }
  }, [])

Still gets the same error.

sleek creek
#

Mh... what version are you using?

dapper idol
#

Every time I save. ๐Ÿ˜„

sleek creek
#

Save?

dapper idol
sleek creek
#

Mh... can you possibly provide a minimal reproduction for this issue?
From the looks of it, the code seems fine so I'm not exactly sure what's up ๐Ÿ˜„

sleek creek
#

Seems like the issue is just caused by hot-reload and not really by the re-render of app itself mh

#

If I remove useMemo then the "real" issue that's documented starts, you get the warning spammed constantly in the console

dapper idol
#

Ok, so I can just safely ignore this then?

sleek creek
#

If there's no actual issues appearing in your app and you don't happen to end in some infinite-rerender loop, I'd say yes ๐Ÿ˜„

dapper idol