1.0.14 • Published 4 years ago

@achievewithoutborders/file-upload-client v1.0.14

Weekly downloads
1
License
ISC
Repository
-
Last release
4 years ago

@achievewithoutborders/file-upload-client

React File Upload Dialog

Installing

$ npm install @achievewithoutborders/file-upload-client --save

Props

Prop nameDescriptionDefault valueExample values
nameName of fielddoctor_name
textValue that will be display on screenDoctor's Name
onChangeEvent that will be called when adding/removing item() => {}function(files) { handleOnChange({ index, files })}
acceptsArray of allowed file typesAll'image/*'(https://www.w3schools.com/tags/att_input_accept.asp)

Example

import React from 'react'
import FileUpload from '@achievewithoutborders/file-upload-client'

export default function FileUploadPage (props) {
  const [items, setItems] = React.useState([
    { 
      name: 'doctors_resume', 
      text: `Doctor's Resume`, 
      accepts: ['image/*'] 
    },
    { 
      name: 'copy_of_certificate',
      text: `Copy of Certificate`,  
      accepts: ['application/pdf'] 
    }
  ])

  const handleOnChange = ({ index, files }) => {
    setItems(state =>
      state.map((item, _index) => {
        if (_index === index) item.files = files
        return item
      })
    )
  }

  return (
    <div>
    {items.map((item, index) => (
      <FileUpload 
        key={item.name} 
        name={item.name} 
        text={item.text} 
        accepts={item.accepts} 
        onChange={files => handleOnChange({ index, files })} 
      />
    ))}
    </div>
  )
}

License

MIT

1.0.14

4 years ago

1.0.11

4 years ago

1.0.13

4 years ago

1.0.12

4 years ago

1.0.10

4 years ago

1.0.8

4 years ago

1.0.7

4 years ago

1.0.6

4 years ago

1.0.5

4 years ago

1.0.2

4 years ago

1.0.4

4 years ago

1.0.3

4 years ago

1.0.1

4 years ago

1.0.0

4 years ago