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

"WeakMap key undefined must be an object" on deleting an item from the collection #169

Open
zspitz opened this issue Sep 17, 2024 · 1 comment

Comments

@zspitz
Copy link

zspitz commented Sep 17, 2024

Describe the bug
I have a collection of items which I pass into Masonry. When I delete an item, recreate the collection, and thus rerender the component holding the Masonry, I get "WeakMap key undefined must be an object".

To Reproduce

  1. Go to the appropriate route/component (loader loads the items, Masonry loads successfully)
  2. Click on the delete button of the item (asynchronously, item is POST-ed to the relevant route, which reruns the loader, returning a new collection)
  3. The error appears

Expected behavior
The component should render successfully.

Screenshots
1.
image

image

Desktop (please complete the following information):

  • OS: Windows
  • Browser Firefox / Chrome
  • Version Firefox 130.0 / 128.0.6613.138

Smartphone (please complete the following information):

(not tested)

Additional context
(May or may not be relevant.) The collection is retrieved by a React Router Ioader into the component via the useLoaderData hook; i.e. not some internal state.

I delete the item using an async function; POST-ing to the React Route of the component and thus triggering the loader to run again, and the component to re-render.

Stack trace:

TypeError: WeakMap key undefined must be an object
    s2 index.js:58
    memoize index.js:85
    useMasonry use-masonry.js:108
    range use-positioner.js:177
    search interval-tree.js:353
    range use-positioner.js:177
    useMasonry use-masonry.js:84
    MasonryScroller masonry-scroller.js:21
    React 9
    workLoop scheduler.development.js:266
    flushWork scheduler.development.js:239
    performWorkUntilDeadline scheduler.development.js:533
    js scheduler.development.js:571
    js scheduler.development.js:633
    __require chunk-5WRI5ZAA.js:8
    js index.js:6
    __require chunk-5WRI5ZAA.js:8
    React 2
    __require chunk-5WRI5ZAA.js:8
    js React
    __require chunk-5WRI5ZAA.js:8
    js React
    __require chunk-5WRI5ZAA.js:8
    <anonymous> react-dom_client.js:38
@jaredLunde
Copy link
Owner

Duplicate of #12

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

No branches or pull requests

2 participants