Research
Security News
Malicious npm Package Targets Solana Developers and Hijacks Funds
A malicious npm package targets Solana developers, rerouting funds in 2% of transactions to a hardcoded address.
@dnd-kit/core
Advanced tools
dnd kit – a lightweight React library for building performant and accessible drag and drop experiences
The @dnd-kit/core package provides a comprehensive set of tools for building complex drag and drop interfaces with ease. It is designed to be highly customizable and extensible, allowing developers to implement a wide range of drag and drop scenarios, from simple list reordering to complex nested structures and beyond. The core package focuses on providing the fundamental building blocks for drag and drop functionality, leaving UI and styling decisions up to the developer.
Basic Drag and Drop
This feature allows for the implementation of basic drag and drop functionality within your application. The DndContext component is used to wrap around the draggable elements, providing the necessary context for drag and drop interactions.
{"import {DndContext} from '@dnd-kit/core';
function App() {
return (
<DndContext>
{/* Your draggable items here */}
</DndContext>
);
}"}
Sorting
This feature enables sorting functionality within a list of items. By using the DndContext in combination with sensors and a sorting utility function like arrayMove, developers can easily implement draggable lists where items can be reordered.
{"import {DndContext, useSensor, PointerSensor} from '@dnd-kit/core';
import {arrayMove} from '@dnd-kit/sortable';
function App() {
const sensors = [useSensor(PointerSensor)];
const handleDragEnd = (event) => {
const {active, over} = event;
if (active.id !== over.id) {
setItems((items) => {
const oldIndex = items.findIndex((item) => item.id === active.id);
const newIndex = items.findIndex((item) => item.id === over.id);
return arrayMove(items, oldIndex, newIndex);
});
}
};
return (
<DndContext sensors={sensors} onDragEnd={handleDragEnd}>
{/* Your sortable items here */}
</DndContext>
);
}"}
react-beautiful-dnd is a popular drag and drop library for React. It offers a high-level API that focuses on creating beautiful, fluid, and accessible drag and drop lists. Compared to @dnd-kit/core, react-beautiful-dnd is more opinionated in terms of its design and functionality, providing out-of-the-box solutions for list reordering but may not offer the same level of customization and control for more complex scenarios.
react-dnd is a flexible drag and drop library for React, built on top of the HTML5 drag and drop API. It provides a set of hooks and components to build complex drag and drop interfaces. While react-dnd offers a great deal of flexibility and control, it can have a steeper learning curve compared to @dnd-kit/core. react-dnd's reliance on the HTML5 drag and drop API also means it may not be as suited for touch devices without additional work.
@dnd-kit – a lightweight React library for building performant and accessible drag and drop experiences.
To get started, install the @dnd-kit/core
package via npm or yarn:
npm install @dnd-kit/core
Visit docs.dndkit.com to learn how to get started with @dnd-kit.
FAQs
dnd kit – a lightweight React library for building performant and accessible drag and drop experiences
The npm package @dnd-kit/core receives a total of 1,717,758 weekly downloads. As such, @dnd-kit/core popularity was classified as popular.
We found that @dnd-kit/core demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 0 open source maintainers collaborating on the project.
Did you know?
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.
Research
Security News
A malicious npm package targets Solana developers, rerouting funds in 2% of transactions to a hardcoded address.
Security News
Research
Socket researchers have discovered malicious npm packages targeting crypto developers, stealing credentials and wallet data using spyware delivered through typosquats of popular cryptographic libraries.
Security News
Socket's package search now displays weekly downloads for npm packages, helping developers quickly assess popularity and make more informed decisions.