haltu / muuri

Infinite responsive, sortable, filterable and draggable layouts
https://muuri.dev
MIT License
10.77k stars 643 forks source link

TypeError: Cannot read properties of undefined (reading 'eventController') #549

Open frodolfo-duclo opened 1 year ago

frodolfo-duclo commented 1 year ago

Hello,

I have a React app where I render an array of items in a grid that users can resize and re-arrange. On dragStart I save grid items and the slots (styles) to a data store. I offer the user a Reset button which should restore the original layout on page load. To accomplish this reset functionality, I do the following:

On dragStart

In the Reset function

NOTE: I save the styles above to account for saved layouts that can be loaded -- I also have a Save layout function

So the reset works and I'm able to restore the original layout on page load, whether it's the default layout or a saved layout that was stored. The problem is I replace the grid items with the ones that were saved previously, I am not able to drag the items to change their positions within the grid. I get the following error instead:

TypeError: Cannot read properties of undefined (reading 'eventController')

image

Am I not doing this correctly? What's missing?