react-list-drag-and-drop
TypeScript icon, indicating that this package has built-in type declarations

0.9.2 • Public • Published

React List Drag and Drop

This package has not been tested on mobile browsers or React Native. SORRY!

Build Status


React List Drag and Drop Example

React List Drag and Drop Example

Installation

npm install --save react-list-drag-and-drop

Usage

You must have an Array of items to render in your list.
Instead of rendering it inside a <div> you render it inside a <RLDD> component using a render prop.

import RLDD from 'react-list-drag-and-drop/lib/RLDD';
<RLDD
  items={items}
  itemRenderer={(item) => {
    return (
      <div className="item">{item.title}</div>
    );
  }}
  onChange={this.handleRLDDChange}
/>

Then you need to handle the onChange callback and call setState with the new list. Like this:

  private handleRLDDChange(newItems) {
    this.setState({ items: newItems });
  }

Each item must be of type Object and have an id property of type number.

You can play around with the examples

Typescript

Edit Draggable List for React + Typescript

Javascript

Edit Draggable List for React + Typescript

Dependencies (0)

    Dev Dependencies (10)

    Package Sidebar

    Install

    npm i react-list-drag-and-drop

    Weekly Downloads

    828

    Version

    0.9.2

    License

    none

    Unpacked Size

    44.8 kB

    Total Files

    23

    Last publish

    Collaborators

    • julian-g