react-sortable-hoc icon indicating copy to clipboard operation
react-sortable-hoc copied to clipboard

Can not read property ownerDocument of null

Open anubhav04 opened this issue 6 years ago • 7 comments

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

anubhav04 avatar May 17 '19 13:05 anubhav04

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.

jzambrano12 avatar Jun 05 '19 14:06 jzambrano12

Yep same issue here

arjan avatar Jun 11 '19 09:06 arjan

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>

freshcoat avatar Jun 14 '19 09:06 freshcoat

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

jedierikb avatar May 29 '20 02:05 jedierikb

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.

dougmartin avatar Aug 24 '20 13:08 dougmartin

who can answer it

beewolf233 avatar Dec 09 '21 12:12 beewolf233

@beewolf233 did you ever find an answer?

flamekiller22 avatar Nov 13 '22 23:11 flamekiller22