Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@rameshupadhaya/react-native-dnd-board

Package Overview
Dependencies
Maintainers
1
Versions
1
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@rameshupadhaya/react-native-dnd-board

Drag and drop Kanban board like Trello

  • 1.0.0
  • latest
  • Source
  • npm
  • Socket score

Version published
Maintainers
1
Created
Source

React Native DnD Board

A drag and drop Kanban board for React Native using Reanimated (V1) and React Native Gesture Handler.

Installation

Step 1:

Install Reanimated V1.

Step 2:

Install React Native Gesture Handler.

Make sure your MainActivity.java was updated by follow all Android instructions.

React Native Gesture Handler IMPORTANT NOTE: If you're using wix/react-native-navigation, please wrap your board screen using gestureHandlerRootHOC (View RNGH docs for more details). If not do it, your board won't work.

Step 3:

Install this package using npm or yarn

with npm:

npm install react-native-dnd-board

with yarn:

yarn add react-native-dnd-board

API reference

The package exports a Board component which is the one you'd use to render the dnd board and a Repository class to handle column, row layout.

Board

PropertyTypeRequiredDescription
repositoryRepositoryyesObject that holds data
renderRow({ item, index }) => {}yesFunction responsible for rendering row item
renderColumnWrapper({ item, index, columnComponent, layoutProps }) => {}yesFunction responsible for rendering wrapper of the column
onRowPress(row) => {}noFunction invoked when row pressed
onDragStart() => {}noFunction invoked when drag is started
onDragEnd(fromColumnId, toColumnId, row) => {}noFunction invoked when drag is finished
styleStylePropnoStyle of the board
columnWidthnumbernoInitial min column width
accessoryRightfunction|ViewnoRender end of the board. Useful when rendering virtual add more column.
activeRowStyleStylePropnoA custom style for the row when being dragged.
activeRowRotationnumbernoDegrees to rotate the row when being dragged. Default is 8.
xScrollThresholdnumbernoOffset from X to calculate scroll from. Default is 50.
yScrollThresholdnumbernoOffset from Y for the rows. Default is 50.
dragSpeedFactornumbernoWhen dragging you can accelerate the scrollTo position. Default is 1.

Repository

Update repository data:
repository.updateData(data);
Handle column data:
repository.addColumn(data);
repository.updateColumn(columnId, data);
repository.deleteColumn(columnId);
Handle row data:
repository.addRow(columnId, data);
repository.updateRow(rowId, data);
repository.deleteRow(rowId);
Get rows with index updated:
const { rows } = repository.getItemsChanged();

Example

Usage

You need to build Repository

import Board, { Repository } from "react-native-dnd-board";

const mockData = [
  {
    id: "1",
    name: "Column 1",
    rows: [
      {
        id: "11",
        name: "Row 1 (Column 1)",
      },
      {
        id: "12",
        name: "Row 2 (Column 1)",
      },
    ],
  },
  {
    id: "2",
    name: "Column 2",
    rows: [
      {
        id: "21",
        name: "Row 1 (Column 2)",
      },
    ],
  },
];

const [repository, setRepository] = useState(new Repository(mockData));

Render the Board

<Board
  repository={repository}
  renderRow={renderCard}
  renderColumnWrapper={renderColumnWrapper}
  onRowPress={onCardPress}
  onDragEnd={onDragEnd}
/>

renderColumnWrapper function

const renderColumnWrapper = ({ item, columnComponent, layoutProps }) => {
  return (
    <View style={styles.column} {...layoutProps}>
      <Text style={styles.columnName}>{item.name}</Text>
      {columnComponent}
    </View>
  );
};

IMPORTANT: You need pass layoutProps to wrapper view props and columnComponent must be rendered inside renderColumnWrapper fuction.

See example for more details.

Performance

We're trying to improve board performance. If you have a better solution, please open a issue or pull request. Best regards!

Keywords

FAQs

Package last updated on 28 Apr 2023

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

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc