New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

react-use-downloader

Package Overview
Dependencies
Maintainers
1
Versions
20
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

react-use-downloader

Creates a download handler with time elapsed

  • 1.0.0
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
0
decreased by-100%
Maintainers
1
Weekly downloads
 
Created
Source
traffic

react-use-downloader

Creates a download handler function and gives progress information.

NPM


Table of Contents


Running example

TODO


Install

npm install --save react-use-downloader

Usage

import React from "react";
import useDownload from "react-use-downloader";

export default function App() {
  const { size, elapsed, percentage, download, error } = useDownload();

  const fileUrl = "https://olavoparno.github.io/saywololo/sounds/Wololo1.wav";

  return (
    <div className="App">
      <button onClick={() => download(fileUrl, "wololo")}>
        Click to download file
      </button>
      <p>
        Download size {size} bytes and {percentage}
      </p>
      <p>Elapsed time {elapsed}s</p>
      {error && <p>possible error {JSON.stringify(error)}</p>}
    </div>
  );
}

Documentation

useDownload() returns:

  • An object with the following keys:

    1. elapsed (in seconds)
    2. percentage (a percentage string)
    3. size (size in bytes)
    4. download (a download function handler)
    • arguments, both as string: {downloadUrl, filename}
    1. error (an error object from the fetch request)
const { size, elapsed, percentage, download, error } = useDownload();

License

react-use-downloader is MIT licensed.


This hook is created using create-react-hook.

FAQs

Package last updated on 21 Feb 2021

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