question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Compatibility with React 18?

See original GitHub issue

I just updated my app to React 18 and now I get an error on DndContext:

Uncaught Error: Maximum update depth exceeded.

It seems that I only have it on sortable multiple containers when I move items between containers. Sometimes it works and sometimes I get the error.

I don’t have this problem with React 17, is dnd-kit compatible with React 18?

Issue Analytics

  • State:closed
  • Created a year ago
  • Comments:5 (2 by maintainers)

github_iconTop GitHub Comments

1reaction
claudericcommented, Jun 9, 2022

Assuming you copied the custom collision detection strategy in the Multiple Containers example:

const collisionDetectionStrategy: CollisionDetection = useCallback(
  (args) => {
    if (activeId && activeId in items) {
      return closestCenter({
        ...args,
        droppableContainers: args.droppableContainers.filter(
          (container) => container.id in items
        ),
      });
    }

    // Start by finding any intersecting droppable
-   const pointerIntersections = pointerWithin(args);
+   const intersections = args.pointerCoordinates ? pointerWithin(args) : rectIntersection(args);
-   const intersections =
-     pointerIntersections.length > 0
-       ? // If there are droppables intersecting with the pointer, return those
-         pointerIntersections
-       : rectIntersection(args);
    let overId = getFirstCollision(intersections, 'id');
0reactions
darren10201commented, Sep 7, 2022

Assuming you copied the custom collision detection strategy in the Multiple Containers example:

const collisionDetectionStrategy: CollisionDetection = useCallback(
  (args) => {
    if (activeId && activeId in items) {
      return closestCenter({
        ...args,
        droppableContainers: args.droppableContainers.filter(
          (container) => container.id in items
        ),
      });
    }

    // Start by finding any intersecting droppable
-   const pointerIntersections = pointerWithin(args);
+   const intersections = args.pointerCoordinates ? pointerWithin(args) : rectIntersection(args);
-   const intersections =
-     pointerIntersections.length > 0
-       ? // If there are droppables intersecting with the pointer, return those
-         pointerIntersections
-       : rectIntersection(args);
    let overId = getFirstCollision(intersections, 'id');

its still happening unexpectedly. especially when its between two containers. I have one horizontal list on top and a row of vertical lists. the error occurs sometimes when a draggable is near the horizontal .

Read more comments on GitHub >

github_iconTop Results From Across the Web

React v18.0 – React Blog
In this post, we'll give an overview of what's new in React 18, ... Suspense in React 18 works best when combined with...
Read more >
Partial list of React 18 compatible library releases #113 - GitHub
Let's use this discussion to track libraries that are known to be compatible with React 18, or have published a React 18-compatible prerelease....
Read more >
React 18 & React Native
tl;dr: The first version of React Native compatible with React 18 is 0.69.0. In order to use the new features in React 18...
Read more >
What's Coming In React 18? - How-To Geek
To take advantage of all the features, you'll need to upgrade your project and may encounter some breaking changes. React 18 is still ......
Read more >
Everything You Should Know About React 18 | Syncfusion Blogs
Syncfusion React JS UI components will always be compatible with the latest React versions. We will include support for React 18 after it ......
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found