react-image-to-file

Allows react web dev implementing the functionality of downloading an image by clicking on a button

Usage no npm install needed!

<script type="module">
  import reactImageToFile from 'https://cdn.skypack.dev/react-image-to-file';
</script>

README

react-image-to-file

Allows react web dev implementing the functionality of downloading an image by clicking on a button ( Hooks only )

NPM JavaScript Style Guide

Install

npm install --save react-image-to-file

Usage

import React from 'react'
import { useDownloadImg } from 'react-image-to-file'

const App = () => {
  const downloadImg = useDownloadImg()

  const onDownloadImg = () => {
    downloadImg({elementID: "my-image", fileName: "my-image"})
  }
  
  return (
    <div>
      <img
        id="my-image"
        alt='Your own'
        src='https://source.unsplash.com/random'
      />
      <button onClick={onDownloadImg}>download img</button>
    </div>
  )
}

export default App

License

MIT © hkhattabi