Home Reference Source
import File from 'prg-form/src/File.jsx'
public class | source

File

Extends:

ComponentBaseInput → File

File upload component In addition to {BaseInput} has theese props:

PropTypes

property type type signature description
name string required input name (you can use dots and array indexes)
label string input label
className string input class
controlClass string surrounding paragraph class
value any use, when input is operated outside <Form>
onChange function (value, input) => {} fired, when input is changed
onFocus function (input) => {} fired, when input is focused
onBlur function (input) => {} fired, when input is blured
required boolean input is required - HTML attribute
iconBefore any content shown before input
multiple boolean allows to set more files - the value will be an array

Example:

// as single file
<File
    name="inputName"
    iconBefore={<i className="fa fa-meetup" />}
    onChange={(file) => file instanceof File} // native File object
/>

// as multiple files files
<File
    name="inputName[]" // do not forget to use with brackets
    iconBefore={<i className="fa fa-meetup" />}
    onChange={(files) => Array.isArray(files) && files[0] instanceof File} // native File object
/>

Inherited Summary

From class BaseInput
public

getValue(): any

Returns input value

public

resetValue(value: *)

Reset and clean the validation errors

public

setError(error: string)

Show error

public

setValue(value: any): any

Set new value to input