Giter VIP home page Giter VIP logo

react-fileupload-progress's Introduction

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

  • url: File upload endpoint url. React.PropTypes.string.isRequired
  • method: Http request method. React.PropTypes.string.isRequired
Events

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

  • onProgress: Called when xhr was loaded. Third parameter is the progress of uploading process(0 ~ 100). React.PropTypes.func(e, request, progress)

  • onLoad: Called when xhr was loaded. React.PropTypes.func(e, request)

  • onError: Called when xhr become error. React.PropTypes.func(e, request)

  • onAbort: Called when xhr was aborted. React.PropTypes.func(e, request)

Customization

It is possible to customize view and form.

  • formRenderer: For custom form rendering, Typo is fixed(#4) from v0.2.0 onSubmitHandler should be attach on your custom form's submit event. When onSubmitHandler is called, this component start observe xhr. React.PropTypes.func(onSubmitHandler)

  • formGetter: If custom formRenderer is used, you need to implement this method and must return FormData object. React.PropTypes.func => {return form}

  • progressRenderer: For custom progress rendering, First parameter is the progress of uploading process(0 ~ 100). If xhr has error, second parameter will be true. When third parameter is called, current xhr will be aborted. React.PropTypes.func(progress, hasError, cancelHandler)

  • formCustomizer: Called before xhr send. You can add any custom form parameter(e.g: id, name, etc) with this method. Must return form given as argument. React.PropTypes.func(form) => {return form}

  • beforeSend: Called before xhr send. You can customize xhr(e.g: HTTPHeader, etc) with this method. Must return request given as argument. React.PropTypes.func(request) => {return request}

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

react-fileupload-progress's People

Contributors

dependabot[bot] avatar dvilchez avatar georgeosddev avatar hackley avatar null-none avatar oakley808 avatar predokmif avatar renovate-bot avatar victormier avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar

react-fileupload-progress's Issues

Action Required: Fix Renovate Configuration

There is an error with this repository's Renovate configuration that needs to be fixed. As a precaution, Renovate will stop PRs until it is resolved.

Error type: undefined. Note: this is a nested preset so please contact the preset author if you are unable to fix it yourself.

How to use with text fields and other input controls?

Example the upload field is not required and it still should submit the form, the problem is how to do that with the react-fileupload-progress. Im having problem calling the onSubmit of the FormRenderer if together with other input fields.

Can't get example to run

import React from 'react/addons'; yields Error: Cannot find module 'react/addons' when running the example.

Changing import React from 'react/addons'; to import React from 'react/addons'; gets rid of the addon error but yields Uncaught TypeError: _react2.default.render is not a function

I was able to use the component in my react project, this seems to just be an issue with the implementation in the example.

Yarn 2 and eslint dependencies

This might be an issue upstream in eslint-plugin-import, but yarn 2 is warning about a dev dependency here.

➤ YN0002: │ react-fileupload-progress@npm:0.5.0 [7e7f8] doesn't provide eslint@^2 || ^3 || ^4 || ^5 || ^6 || ^7.2.0 requested by eslint-plugin-import@npm:2.22.0

Dependency Dashboard

This issue lists Renovate updates and detected dependencies. Read the Dependency Dashboard docs to learn more.

Warning

These dependencies are deprecated:

Datasource Name Replacement PR?
npm babel-eslint Available

Rate-Limited

These updates are currently rate-limited. Click on a checkbox below to force their creation now.

  • Replace dependency babel-eslint with @babel/eslint-parser 7.11.0
  • Update dependency karma-firefox-launcher to v2.1.3
  • Update dependency karma-spec-reporter to v0.0.36
  • Update dependency sinon to v11.1.2
  • Update dependency babel-plugin-istanbul to v6.1.1
  • Update dependency core-js to v3.38.0
  • Update dependency eslint to v7.32.0
  • Update dependency eslint-plugin-import to v2.29.1
  • Update dependency eslint-plugin-react to v7.35.0
  • Update dependency jquery to v3.7.1
  • Update dependency karma-chrome-launcher to v3.2.0
  • Update dependency karma-coverage to v2.2.1
  • Update dependency prop-types to v15.8.1
  • Update dependency babel-plugin-istanbul to v7
  • Update dependency browser-sync to v3
  • Update dependency chai to v5
  • Update dependency eslint to v9
  • Update dependency eslint-config-airbnb to v19
  • Update dependency mocha to v10
  • Update dependency rimraf to v6
  • Update dependency sinon to v18
  • Update react monorepo to v18 (major) (react, react-dom)
  • 🔐 Create all rate-limited PRs at once 🔐

Edited/Blocked

These updates have been manually edited so Renovate will no longer make changes. To discard all commits and start over, click on a checkbox.

Open

These updates have all been created already. Click a checkbox below to force a retry/rebase of any.

Detected dependencies

html
example/index.html
  • normalize 8.0.1
  • html5shiv 3.7.3
  • html5shiv 3.7.3
  • jquery 3.6.0
  • es5-shim 4.5.15
  • es5-shim 4.5.15
npm
package.json
  • babel-plugin-istanbul ^6.0.0
  • core-js 3
  • eslint-plugin-import ^2.17.3
  • object-assign ^4.1.1
  • prop-types ^15.7.2
  • sinon ^11.0.0
  • @babel/cli 7.14.3
  • @babel/core 7.14.3
  • @babel/preset-env 7.14.4
  • @babel/preset-react 7.13.13
  • babel-eslint 10.1.0
  • babelify 10.0.0
  • browser-sync 2.26.14
  • browserify 17.0.0
  • chai 4.3.4
  • eslint 7.28.0
  • eslint-config-airbnb 18.2.1
  • eslint-plugin-react 7.24.0
  • express 4.17.1
  • karma 6.3.3
  • karma-browserify 8.0.0
  • karma-chai 0.1.0
  • karma-chrome-launcher 3.1.0
  • karma-cli 2.0.0
  • karma-coverage 2.0.3
  • karma-firefox-launcher 2.1.1
  • karma-mocha 2.0.1
  • karma-safari-launcher 1.0.0
  • karma-spec-reporter 0.0.32
  • mocha 9.0.0
  • multer 1.4.2
  • react 17.0.2
  • react-addons-test-utils 15.6.2
  • react-dom 17.0.2
  • rimraf 3.0.2
  • sinon 11.1.1
  • watchify 4.0.0
  • react 16.x || 17.x
  • react-dom 16.x || 17.x
travis
.travis.yml

  • Check this box to trigger a request for Renovate to run again on this repository

Typo

formRnederer is used throughout the code + documentation. I'm assuming that's a typo?

Headers

Hi
how can I add custom header values ? ( for authorization and ... )

import path error?

When I tried to import FileUploadProgress as follows:
import FileUploadProgress from 'fileUploadProgress';
... like the example in the README, I would get an error:
Module not found: Error: Cannot resolve module 'fileUploadProgress' in

What did work for me was using:
import FileUploadProgress from 'react-fileupload-progress/lib/index';

I had installed using the example npm command.

onFileChange

How can I trigger onFileChange icon , I want to load a thumb of the file when the input changes , where is the best place to trigger that , insights on how to do it is higly appreciated.

peer dependency versioning issue?

I'm sort of an npm-newbie, but I've had some struggles with react versions between react 0.15 and react-fileupload-progress.

Bootstrapping a react app using
https://github.com/facebookincubator/create-react-app

gives a "recommended" base version of react/webpack/babel etc.
I create a a clean demo project like so:
create-react-app reactuploadtest

However, adding react-fileupload-progress gives me some warnings about unmet peer dependencies:

epaulson:~/Desktop/django-experiments/drf/react-bootstrap-tests/reactuploadtest $ npm install --save react-fileupload-progress
[email protected] /Users/epaulson/Desktop/django-experiments/drf/react-bootstrap-tests/reactuploadtest
├── UNMET PEER DEPENDENCY [email protected]
├── UNMET PEER DEPENDENCY [email protected]
└─┬ [email protected]
├─┬ [email protected]
│ ├─┬ [email protected]
│ │ ├─┬ [email protected]
│ │ │ ├── [email protected]
│ │ │ ├─┬ [email protected]
│ │ │ │ ├─┬ [email protected]
│ │ │ │ │ └── [email protected]
│ │ │ │ ├─┬ [email protected]
│ │ │ │ │ ├── [email protected]
│ │ │ │ │ └── [email protected]
│ │ │ │ ├─┬ [email protected]
npm WARN [email protected] requires a peer of react@^0.14.6 but none was installed.
npm WARN [email protected] requires a peer of react-dom@^0.14.6 but none was installed.
? [email protected]
│ │ │ │ │ │ └── [email protected]
│ │ │ │ │ ├─┬ [email protected]
│ │ │ │ │ │ └─┬ [email protected]
│ │ │ │ │ │ ├── [email protected]
│ │ │ │ │ │ └── [email protected]
│ │ │ │ │ ├── [email protected]
│ │ │ │ │ └── [email protected]
│ │ │ │ ├── [email protected]
│ │ │ │ ├─┬ [email protected]
│ │ │ │ │ └── [email protected]
│ │ │ │ ├── [email protected]
│ │ │ │ ├── [email protected]
│ │ │ │ └─┬ [email protected]
│ │ │ │ ├── [email protected]
│ │ │ │ ├── [email protected]
│ │ │ │ └── [email protected]
│ │ │ ├── [email protected]
│ │ │ ├── [email protected]
│ │ │ └─┬ [email protected]
│ │ │ └── [email protected]
│ │ └── [email protected]
│ └─┬ [email protected]
│ └── [email protected]
├── [email protected]
└─┬ [email protected]
├── [email protected]
├── [email protected]
├── [email protected]
└─┬ [email protected]
└── [email protected]

In my other project where I was using react-fileupload, I ran into all sorts of trouble with strange complaints from react telling me that it might have multiple versions installed, similar to some of the troubles reported here:
https://gist.github.com/jimfb/4faa6cbfb1ef476bd105
(it's possible I somehow made things worse. I tried deleting my node_modules and reinstalling with npm install a few times)

I ultimately solved them by just forking react-fileupload and bumping the version in package.json in my repo to be the current release, but that seems like it's the wrong way to solve the problem. (though I don't know what the right way to solve it might be)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.