Big News: Socket raises $60M Series C at a $1B valuation to secure software supply chains for AI-driven development.Announcement
Sign In

react-smartui-fileupload

Package Overview
Dependencies
Maintainers
1
Versions
6
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

react-smartui-fileupload

React fileupload component for smartui project

latest
Source
npmnpm
Version
0.6.0
Version published
Maintainers
1
Created
Source

React FileUpload Component

Asynchronous FileUpload Component for SmartUI Project

Special Thanks GA-MO

This Repository created by React Component Boilerplate

React Component boilerplate for creating new Reac Compoment and everything you need to get started.

https://github.com/GA-MO/react-component-npm-package-boilerplate/

Prerequisite

Please import font-awesome to your project

Getting Started

$ npm install react-smartui-fileupload

Quick Usage

Copy following code to your react component

import FileUploadInput from 'react-smartui-fileupload'
import 'react-smartui-fileupload/css/style.css'
.
.
.
onUpload = (name, file) => {
  return new Promise((resolve, reject) => {
    // promise to upload file
    setTimeout(() => {
      resolve(true)
    }, 500)
  })
}

onDelete = (name, file) => {
  return new Promise((resolve, reject) => {
    // promise to delete file
    setTimeout(() => {
      resolve(true)
    }, 500)
  })
}

render() {
  return (
    <FileUploadInput
      name={'file'}
      label={'File'}
      fileName={''}
      onUpload={this.onUpload}
      onDelete={this.onDelete}
    />
  )
}

Error Handling

This component can handle error in case property onUpload or onDelete is rejected and it will grab error.message (new Error('Something error')) to show instead of 'กรุณาเลือกไฟล์'

onDelete = (name, file) => {
  return new Promise((resolve, ir) => {
    // promise to delete file
    setTimeout(() => {
      reject(new Error('Cannot upload file'))
    }, 500)
  })
}

Props

PropertyDescriptionTypeDefault
namename of component for identify each componentString'File'
labelUI text label of componentString''
requiredFlag to render * with redBooleanfalse
fileNameFile's nameString''
asyncFlag to using asynchronous featureBooleantrue
acceptMime types of accept filesString'*'
onDropEvent handler after file is chosenfunction(name, file)null
onUploadEvent handler after file need to uploadfunction(name, file)null
onDeleteEvent handler after button delete is clickedfunction(name, file)null

If you have any suggestions, feel free to contact me mondit.thum@gmail.com Thank you !!

Keywords

react

FAQs

Package last updated on 03 Oct 2017

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