๐Ÿš€ Socket Launch Week ๐Ÿš€ Day 5: Introducing Socket Fix.Learn More โ†’
Socket
Sign inDemoInstall
Socket

@thaddeusjiang/react-sortable-list

Package Overview
Dependencies
Maintainers
1
Versions
8
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@thaddeusjiang/react-sortable-list

Welcome to @thaddeusjiang/react-sortable-list ๐Ÿ‘‹ <img alt="Version" src="https://img.shields.io/npm/v/@thaddeusjiang/react-sortab

0.0.3
Source
npm
Version published
Maintainers
1
Created
Source

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

Keywords

React

FAQs

Package last updated on 15 Apr 2022

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts