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

react-files

Package Overview
Dependencies
Maintainers
1
Versions
38
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

react-files

A file input (dropzone) management component for React

  • 1.0.0
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
10K
increased by5.45%
Maintainers
1
Weekly downloads
 
Created
Source

react-files

A file input (dropzone) management component for React

Demo

Alt text

Installation

Install from NPM and include it in your own React build process (using Browserify, Webpack, etc).

npm install react-files --save

Usage

var FilesDemo = React.createClass({
  onSubmit: function(files) {
    console.log(files)
  },

  onUnaccepted: function(file) {
    console.log(file.name + ' is not a valid file type.')
  },

  render: function() {
    return (
      <div className="files">
        <Files
          onSubmit={this.onSubmit}
          onUnaccepted={this.onUnaccepted}
          accepts={['image/*', 'application/pdf', '.txt']}
        />
      </div>
    )
  }
})

ReactDOM.render(<FilesDemo />, document.getElementById('container'))

Props

onSubmit(files) - Function

Perform work on files added when submit is clicked.

onUnaccepted(file) - Function

Perform work or notify the user when a file is dropped/added that is unacceptable.

accepts - Array of String

Control what types of generic/specific MIME types, or specific extensions can be dropped/added.

Example

accepts={['image/*', 'video/mp4', 'audio/*', '.pdf', '.txt']}

Styling

Be sure to style your Files component, available selectors are (view style.css):

  • .files-container
  • .files-dropzone-outer
  • .files-dropzone
  • .files-dropzone:before
  • .files-dropzone-ondragenter
  • .files-buttons
  • .files-button-submit
  • .files-button-submit:before
  • .files-button-clear
  • .files-button-clear:before
  • .files-list
  • .files-list ul
  • .files-list li:last-child
  • .files-list-item
  • .files-list-item-content
  • .files-list-item-content-item
  • .files-list-item-content-item-1
  • .files-list-item-content-item-2
  • .files-list-item-preview
  • .files-list-item-preview-image
  • .files-list-item-preview-extension
  • .files-list-item-remove
  • .files-list-item-remove-image

Test (todo)

npm test

License

MIT. Copyright (c) 2016 Jared Reich.

Keywords

FAQs

Package last updated on 25 Aug 2016

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