Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

react-images-uploading

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-images-uploading

A simple images uploader without UI. Building by yourself

  • 1.0.3
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
31K
decreased by-0.21%
Maintainers
1
Weekly downloads
 
Created
Source

react-images-uploading

NPM JavaScript Style Guide

Images uploader

A simple images uploader without UI. Building by yourself.

#Demo

Install

npm install --save react-images-uploading

Usage

import * as React from "react";

import ImageUploading from "react-images-uploading";
// { ImageUploadingPropsType, ImageListType, ImageType } is type for typescript

const mode = "single";
const maxNumber = 10;
class Example extends React.Component {
  onChange = imageList => {
    // data for submit
  };

  render() {
    return (
      <ImageUploading mode={mode} onChange={onChange} maxNumber={maxNumber}>
        {({ imageList, onImageUpload, onImageRemoveAll }) => (
          // write your building UI
          <div>
            <button onClick={onImageUpload}>Upload images</button>
            <button onClick={onImageRemoveAll}>Remove all images</button>

            {imageList.map(image => (
              <div key={image.key}>
                <img src={image.dataURL} />
                <button onClick={image.onUpdate}>Update</button>
                <button onClick={image.onRemove}>Remove</button>
              </div>
            ))}
          </div>
        )}
      </ImageUploading>
    );
  }
}

Props

parametertypeoptionsdefaultdescription
modestringsingle/multiplesingleSelect just one or multiple images
maxNumbernumber100Number of images user can select if mode = "multiple"
onChangefunctionCalled every update
defaultValuearray[{dataURL: ... }, ...]Init data

Exported options

parametertypedescription
imageListarrayList of images for render. Each item in imageList has some options below.
imageList[index].keystringGenerate filename
imageList[index].dataURLstringUrl image or base64
imageList[index].onUpdatefunctionCall function for replace a new image on current position
imageList[index].onRemovefunctionCall function for remove current image
onImageUploadfunctionCall for upload new image(s)
onImageRemoveAllfunctionCall for remove all image(s)

License

MIT ©

Keywords

FAQs

Package last updated on 03 Jan 2020

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