elementalui / elemental

A flexible and beautiful UI framework for React.js
elemental-ui.com
MIT License
4.31k stars 216 forks source link

Use props.file in FileUpload #180

Open stefansvard opened 8 years ago

stefansvard commented 8 years ago

Hi!

As far as I can see (in FileUpload.js) propTypes: { buttonLabelChange: React.PropTypes.string, buttonLabelInitial: React.PropTypes.string, disabled: React.PropTypes.bool, file: React.PropTypes.object, onChange: React.PropTypes.func } file can be sent in as props.

but in render there is no connection to this props but only to the file set in the components state.

So e.g. if user uses the FileDragAndDrop there is no way to inject the dropped file into the FileUpload component.

By changing in the render function to prioritize the props.file value, if set, this works nicely var file = this.props.file || _state.file;

Don't know if this breaks anything else but I post it here if it here and hopefully it helps this great project and perhaps could be included in a future release

BR Stefan

jossmac commented 7 years ago

Sounds good!

Any chance we can get a PR on this @stefansvard?