draggable-react-component
v1.0.10
Published
draggable-react-component is a simple React component and hook for making elements in your application draggable. This package provides an easy-to-use API for creating draggable elements in your React application.
Downloads
27
Readme
Introduction
draggable-react-component is a simple React component and hook for making elements in your application draggable. This package provides an easy-to-use API for creating draggable elements in your React application.
Installation
To install the draggable-react-component package, run the following command in your project's terminal:
npm install draggable-react-component
Usage
The draggable-react-component package includes two exports: the Draggable component and the useDraggable hook.
The Draggable Component
The Draggable component is a simple wrapper around a div that makes its children draggable. It uses the useDraggable hook internally to manage the draggable state.
Here's an example of how to use the Draggable component in your application:
import React from "react";
import Draggable from "draggable-react-component";
const MyDraggableElement = () => {
return (
<Draggable>
<div>I am a draggable element!</div>
</Draggable>
);
};
Conclusion
The draggable-react-component package provides a simple and easy-to-use solution for making elements in your React application draggable. Whether you're looking to use the Draggable component or the useDraggable hook, this package provides everything you need to get started.