redux-form:覆盖字段的onChange()函数

时间:2016-07-04 01:49:52

标签: javascript forms file-upload reactjs redux-form

我正在尝试使用基于reactjs的应用中的DropZone组件来上传多个文件。我的redux-form有一个名为pics的字段,以下内容适用于上传单个文件:

render()函数中的

<Row>
                  <Dropzone
                     { ...pics }
                     onDrop={ this.dropFile }
                 >
                   <div>Try dropping some files here, or click to select files to upload.</div>
                 </Dropzone>
              </Row>

我的dropFile()函数

dropFile(files, evt) {
        console.log('received files: ', files);
        this.props.fields.pics.onChange(files); // use *files* to update the field pics value here        
    }

虽然上传单个文件有效,但它不允许上传多个文件(将多个文件丢弃到DropZone中)。我想原因是onChange函数会覆盖以前的文件,所以我想知道是否可以在redux-form中覆盖某个字段上的 onChange 函数。

修改

以hacky的方式,我让减速器听取redux-form/CHANGE事件,但我想知道是否有更好的方法。感谢

0 个答案:

没有答案