React-sortable-hoc: Can not read property ownerDocument of null

Created on 17 May 2019  ·  5Comments  ·  Source: clauderic/react-sortable-hoc

I am getting TypeError: Cannot read property 'ownerDocument' of null even if all the required props are passed to Container and element.

Line Number: 429
File: SortableContainer/index.js

Most helpful comment

You have to wrap your items with an element;

error;

indexes.map((index: number) => (
   <div key={`${name}-${index}`}>
      ...
   </div>
))

Fix;

<div>
   {indexes.map((index: number) => (
     <div key={`${name}-${index}`}>
       ...
     </div>
   ))}
</div>

All 5 comments

I'm going through the same thing. It happens when I try to iterate with a .map function the items that are in my initial state.

Yep same issue here

You have to wrap your items with an element;

error;

indexes.map((index: number) => (
   <div key={`${name}-${index}`}>
      ...
   </div>
))

Fix;

<div>
   {indexes.map((index: number) => (
     <div key={`${name}-${index}`}>
       ...
     </div>
   ))}
</div>

Would be nice if React.Fragment could be used for this purpose.

One other thing to look out for - if you wrap an element whose render exits early and returns undefined/null when there are no items you'll also get this error.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

zhujunwei picture zhujunwei  ·  3Comments

curtd59 picture curtd59  ·  3Comments

ianmstew picture ianmstew  ·  3Comments

sammiwei911 picture sammiwei911  ·  3Comments

Jessidhia picture Jessidhia  ·  4Comments