Security News
Input Validation Vulnerabilities Dominate MITRE's 2024 CWE Top 25 List
MITRE's 2024 CWE Top 25 highlights critical software vulnerabilities like XSS, SQL Injection, and CSRF, reflecting shifts due to a refined ranking methodology.
@flexcodelabs/use-drag-drop-hook
Advanced tools
[![npm](https://img.shields.io/npm/v/@flexcodelabs/use-drag-drop-hook)](https://www.npmjs.com/package/@flexcodelabs/use-drag-drop-hook) [![NPM](https://img.shields.io/npm/l/@flexcodelabs/use-drag-drop-hook)](https://www.npmjs.com/package/@flexcodelabs/use
npm install @flexcodelabs/use-drag-drop-hook
or
yarn add @flexcodelabs/use-drag-drop-hook
...
import useDragAndDrop from '@flexcodelabs/use-drag-drop-hook';
// inside React Fn
const {
dragOver, // returns true if drag over event triggered
setDragOver, // update drag over state
onDragOver, // a function to be called onDrag event
onDragLeave, // a function to be called on drag leave
fileDropError, // returns error if there is any on file drop
setFileDropError, // set errors especially used on validation
} = useDragAndDrop()
...
import useDragAndDrop from '@flexcodelabs/use-drag-drop-hook';
const Test = () => {
const {
dragOver,
onDragOver,
onDragLeave,
fileDropError,
setFileDropError,
} = useDragAndDrop();
const [file, setFile] = useState<any>(null);
const onDrop = (e: any) => {
e.preventDefault();
if (e.dataTransfer.files[0]?.size > 10000) {
setFileDropError("Invalid file size");
}
// do something with the file
setFile(e.dataTransfer.files[0]);
};
return (
<div>
<label
onDrag={onDragOver}
onDragOver={onDragOver}
onDragLeave={onDragLeave}
onDrop={onDrop}
>
{file && <p>{file?.name}</p>}
Drag and Drop your files here
<input type="file" />
{fileDropError && <p>{fileDropError}</p>}
<p>{dragOver && "Drop your files here"}</p>
<p>Max file size = 10Kb</p>
</label>
</div>
);
};
FAQs
[![npm](https://img.shields.io/npm/v/@flexcodelabs/use-drag-drop-hook)](https://www.npmjs.com/package/@flexcodelabs/use-drag-drop-hook) [![NPM](https://img.shields.io/npm/l/@flexcodelabs/use-drag-drop-hook)](https://www.npmjs.com/package/@flexcodelabs/use
The npm package @flexcodelabs/use-drag-drop-hook receives a total of 0 weekly downloads. As such, @flexcodelabs/use-drag-drop-hook popularity was classified as not popular.
We found that @flexcodelabs/use-drag-drop-hook demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 3 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.
Security News
MITRE's 2024 CWE Top 25 highlights critical software vulnerabilities like XSS, SQL Injection, and CSRF, reflecting shifts due to a refined ranking methodology.
Security News
In this segment of the Risky Business podcast, Feross Aboukhadijeh and Patrick Gray discuss the challenges of tracking malware discovered in open source softare.
Research
Security News
A threat actor's playbook for exploiting the npm ecosystem was exposed on the dark web, detailing how to build a blockchain-powered botnet.