georgeOsdDev / react-fileupload-progress

React component of Input file and progress bar
http://georgeosddev.github.io/react-fileupload-progress
MIT License
103 stars 35 forks source link

React-fileupload-progress Build Status npm version

Gyazo

React component of Input file and progress bar. This component watch xhr uploading process, and trigger some events.

Installation

npm install --save react-fileupload-progress

API

FileUploadProgress

Props

Events

These handler will called on XMLHttpRequest's progress events. See also Using XMLHttpRequest on MDN.

Customization

It is possible to customize view and form.

Gyazo

Usage example

'use strict';

import React from 'react';
import FileUploadProgress  from 'react-fileupload-progress';

class App extends React.Component {
  constructor(props) {
    super(props);
  }
  render() {
    return (
      <div>
        <h3>Default style</h3>
        <FileUploadProgress key='ex1' url='http://localhost:3000/api/upload'
          onProgress={(e, request, progress) => {console.log('progress', e, request, progress);}}
          onLoad={ (e, request) => {console.log('load', e, request);}}
          onError={ (e, request) => {console.log('error', e, request);}}
          onAbort={ (e, request) => {console.log('abort', e, request);}}
          />
      </div>
    )
  }
};

React.render(<App/>, document.getElementById('out'));

See also example

npm install # or yarn
npm run start:example

Build

npm run build

Tests

npm test