Skip to content

Children className overridden by parent #115

@ludovic-bekaert

Description

@ludovic-bekaert

Hi,
I'm unable to set a class to the children items.

The following code

const [state, setState] = useState([
  { id: 1, name: "shrek" },
  { id: 2, name: "fiona" }
]);

return (
  <ReactSortable
    className="my-list"
    list={state}
    setList={setState}
  >
    {state.map(item => (
      <div className="my-item" key={item.id}>{item.name}</div>
    ))}
  </ReactSortable>
);

ends up like this

<div class="my-list">
  <div data-id="1" class="my-list">shrek</div>
  <div data-id="2" class="my-list">fiona</div>
</div>

Looks like it comes from a misplaced line in the following commit c93847e

The prevClassName variable is declared at the beginning of the getChildren function. Moving it into the Children.map part fixed the problem locally.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions