🚀 Big News: Socket Acquires Coana to Bring Reachability Analysis to Every Appsec Team.Learn more
Socket
Book a DemoInstallSign in
Socket

image-upload-react

Package Overview
Dependencies
Maintainers
1
Versions
15
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

image-upload-react

react image picker

1.4.5
latest
Source
npm
Version published
Weekly downloads
85
37.1%
Maintainers
1
Weekly downloads
 
Created
Source

image-upload-react

react image picker

NPM JavaScript Style Guide

Demo

Alt text Alt text

Install

npm install --save image-upload-react

Usage

import React, { useState } from 'react'
import ImageUpload from 'image-upload-react'
//important for getting nice style.
import 'image-upload-react/dist/index.css'

function App() {
  const [imageSrc, setImageSrc] = useState()

  const handleImageSelect = (e) => {
    setImageSrc(URL.createObjectURL(e.target.files[0]))
  }

  return (
    <ImageUpload
      handleImageSelect={handleImageSelect}
      imageSrc={imageSrc}
      setImageSrc={setImageSrc}
      style={{
        width: 700,
        height: 500,
        background: 'gold'
      }}
    />
  )
}

export default App

Docs

PropertyDescriptionRequired
handleImageSelectfunction that will get fired when the user pick an image and we will update the state with the piacked filetrue
imageSrcpeace of state to keep track of the slected filetrue
setImageSrcfunction that will update the value in the statetrue
stylestyle object to style the parent div for the ImageUpload componentfalse

License

MIT © Abd-Alwahab

Keywords

react

FAQs

Package last updated on 15 Aug 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