You should focus the logics of your app, not DnD.

Overview

Welcome to @thaddeusjiang/react-sortable-list 👋

Version Documentation Maintenance License: MIT Twitter: ThaddeusJiang

You should focus the logics of your app, not DnD.

🏠 Homepage

Demo

Features

  • Easy Drag & Drop sort items

Install

yarn add @thaddeusjiang/react-sortable-list

Usage

Use Case 1: ItemRender

export const ItemRenderExample: React.VFC = () => {
  const [items, setItems] = useState<SortableItemProps[]>([
    { id: '1', name: 'Item 1' },
    { id: '2', name: 'Item 2' },
    { id: '3', name: 'Item 3' },
  ]);
  return (
    <SortableList
      items={items}
      setItems={setItems}
      itemRender={({ item }: ItemRenderProps) => (
        <div className="w-1/2 h-10 m-8 bg-blue-400 text-center">
          {item.name}
        </div>
      )}
    />
  );
};

Use Case 2: Children

export const ChildrenExample: React.VFC = () => {
  const [items, setItems] = useState<SortableItemProps[]>([
    { id: '1', name: 'Item 1' },
    { id: '2', name: 'Item 2' },
  ]);

  return (
    <SortableList items={items} setItems={setItems}>
      {({ items }: { items: SortableItemProps[] }) => (
        <>
          {items.map((item: SortableItemProps) => (
            <SortableItem key={item.id} id={item.id}>
              {item.name}
            </SortableItem>
          ))}
        </>
      )}
    </SortableList>
  );
};

Development

Storybook

Run inside another terminal:

yarn storybook

Example

Then run the example inside another:

yarn link

cd example
yarn link "@thaddeusjiang/react-sortable-list"
yarn # or yarn to install dependencies
yarn start #

Run tests

yarn run test

Author

👤 Thaddeus Jiang

🤝 Contributing

Contributions, issues and feature requests are welcome!
Feel free to check issues page. You can also take a look at the contributing guide.

Show your support

Give a ⭐️ if this project helped you!

📝 License

Copyright © 2022 Thaddeus Jiang.
This project is MIT licensed.


This README was generated with ❤️ by readme-md-generator

You might also like...

This app helps you keep track of your expenses in months and years. Also, it shows a graph representing those expenses.

This app helps you keep track of your expenses in months and years. Also, it shows a graph representing those expenses.

Expenses Tracker This app helps you keep track of your expenses in months and years. Also, it shows a graph representing those expenses. Built With Ma

Aug 8, 2022

Setup all the linters you like for your react app in 1 minute 🚀

Setup all the linters  you like for your react app in 1 minute 🚀

Create React Linters 🚀 Setup all the linters you like and don't let 💩 slip into your code base! Eslint | Stylelint | Commitlint | Prettier | EditorC

Nov 18, 2022

SafeView allows you to hide senstive information in your app visually.

SafeView allows you to hide senstive information in your app visually.

SafeView SafeView is a component that allows you to hide sensitive information in your app visually, for presentation purposes, and more. Installation

Jun 13, 2022

Open Source Website where you can manage your information and artworks of your fursona(s)

Open Source Website where you can manage your information and artworks of your fursona(s)

MyFursona About this project MyFursona is an open source project where users can manage their artworks, info (such as biography and interests), and lo

Jan 7, 2023

The chat app built with microservice architecture, the app using: Lerna, pm2, GraphQL

The chat app built with microservice architecture, the app using: Lerna, pm2, GraphQL

Microservice Chat App A microservice app! Built With Lerna pm2 Graphql Sequelize Socket.io About The Project Here's why: I want learn socket.io and mi

Aug 27, 2022

Recipe providing mobile app, User selects ingredients in pantry and is then provided recipes for those ingredients. App contains a signup/login, meal planner and grocery list pages.

Recipog Student Information Name Connor de Bruyn Username Destiro Assignment SWEN325 A2 Description “Recipog” is a recipe providing app that allows th

Dec 26, 2021

React-app - Building volume rendering web app with VTK.js,react & HTML Using datasets provided in vtk examples (head for surface rendering and chest for ray casting)

SBE306 Assignment 4 (VTK) data : Directory containing Head and Ankle datasets Description A 3D medical viewer built with vtk-js Team Team Name : team-

Jul 19, 2022

Create Sonnat App - Set up a modern web app which is powered by Sonnat.

Create Sonnat App - Set up a modern web app which is powered by Sonnat.

Jan 31, 2022

"BookStore" is a web app for adding books. It is a Single Page App (SPA) that allows users to add and remove a book from the library

BookStore | M3Wx "BookStore" is a web app for adding and removing books from a library storage. It is a Single Page App (SPA) that allows users to add

Apr 11, 2022
Concircle scanner mobile app is application That helps you scan your order and position and to know if there are exact or not. it's cross-platform app.

Concircle scanner mobile app ⭐ Star on GitHub — it motivates Me a lot! Concircle scanner mobile app is application That helps you scan your order and

Aymen Ouerghui 10 May 7, 2022
:fire: A highly scalable, offline-first foundation with the best developer experience and a focus on performance and best practices.

Start your next react project in seconds A highly scalable, offline-first foundation with the best DX and a focus on performance and best practices Cr

react-boilerplate 28.9k Jan 6, 2023
This is not my code, just trained with "From Scratch - Développement Web" youtube video

React-Countries-API DISCLAIMER FR : Ceci n'est pas mon code, je me suis juste entraîné à partir de la vidéo de From Scratch - Développement Web ! EN :

LejusVDP 1 Jan 4, 2022
shouganaiyo-loader is a cross-platform Frida-based Node.js command-line tool that forces Java processes to load a Java/JVMTI agent regardless of whether or not the JVM has disabled the agent attach API.

shouganaiyo-loader: Forced Entry for Java Agents shouganaiyo-loader is a cross-platform Frida-based Node.js command-line tool that forces Java process

NCC Group Plc 20 Sep 19, 2022
IPL Loader to load IPL's as soon as Player is in range. This also fixes, IPL's not showing on reconnect in debug mode.

ALT-V IPL-Loader IPL Loader to load IPL’s as soon as Player is in range of the IPL Coordinates. This also fixes, IPL’s not showing on reconnect in deb

null 3 Oct 9, 2022
Webpack is an open-source JavaScript module bundler. This includes basic setup files to help me not redo all the setups for webpack when starting a new project.

Webpack Setup Webpack is an open-source JavaScript module bundler. It is made primarily for JavaScript, but it can transform front-end assets such as

Nemwel Boniface 14 Jun 23, 2022
🖱or ⌨️? 🤷‍♀️, but hopefully use-hover-state works on the "user intent" not the "device"

useHoverState() The one aware of keyboard navigation as well ?? npm i use-hover-state A React hook for tracking user interaction with the DOM elements

Marina 10 Aug 11, 2022
Interactive web app where you can Store ,Add and Remove books to organize the books that you've read or the ones willing to read

bookStore Interactive web app where you can Store ,Add and Remove books to organize the books that you've read or the ones willing to read Built With

Yassine Omari 7 Jul 20, 2022
🎉 toastify-react-native allows you to add notifications to your react-native app (ios, android) with ease. No more nonsense!

toastify-react-native ?? toastify-react-native allows you to add notifications to your react-native app (ios, android) with ease. No more nonsense! De

Zahid Ali 29 Oct 11, 2022