use_image_downloader
TypeScript icon, indicating that this package has built-in type declarations

1.0.2 • Public • Published

use_image_downloader

A custom React hook for downloading and saving images with ease.

Installation

Install the package using npm:

npm install use_image_downloader

Usage

Example Usage in a Component

Importing the Hook

import { useImageDownloader } from 'use_image_downloader';

Using the Hook

function App() {
  const downloadImage = useImageDownloader()

  return (
    <div>
      <button onClick={()=>downloadImage('*link*', 'animal.png')}>download</button>
    </div>
  )
}

API

useImageDownloader()

Returns a function. Let's save it in downloadImage variable.

To download an image we need to call the downloadImage('link of the image', 'file name.png or .jpg') which takes two parameters

onClick={()=> downloadImage('link of the image', 'file name.png or .jpg')}

Parameters

  • url: string - The URL of the image to be downloaded.

  • filename: string - The name to save the image as which must include filetype like .png or .jpg etc.

/use_image_downloader/

    Package Sidebar

    Install

    npm i use_image_downloader

    Weekly Downloads

    0

    Version

    1.0.2

    License

    ISC

    Unpacked Size

    3.88 kB

    Total Files

    9

    Last publish

    Collaborators

    • imsyntn