SortableJS / react-sortablejs

React bindings for SortableJS
http://sortablejs.github.io/react-sortablejs/
MIT License
1.98k stars 206 forks source link

Cannot read properties of null (reading 'props'), found the issue #284

Open leqwasd opened 10 months ago

leqwasd commented 10 months ago

I think I found an issue with one condition here: https://github.com/SortableJS/react-sortablejs/blob/48e8780a1c92e071da61a67e95acd8212d906523/src/react-sortable.tsx#L121

My render looks like this (psudo)

interface Data {
  columns: string[];
  optionalColumns?: string[];
}
[..]
return (
  <ReactSortable ...>
    {optionalColumns?.map(x => <Item x={x} />)}
    {columns.map(x => <Item x={x} />)}
  </ReactSortable>
)

It fails for me on line: https://github.com/SortableJS/react-sortablejs/blob/48e8780a1c92e071da61a67e95acd8212d906523/src/react-sortable.tsx#L124

Because the guard at line 121 does not handle this...

null === undefined // false

Shouldn't there be just child == null ? Double eq with null, which will handle nulls and undefineds?