FileUploadList isn't populated by redux-form
In 8e76691b, the @pubsweet/ui
components concerned with file upload were reorganised. As part of this reorg, Files
(renamed to FileUploadList
) stopped expecting a value
prop and started expecting a files
prop instead:
class Files extends React.Component {
constructor(props) {
super(props)
this.state = {
values: props.value || [],
uploads: [],
}
}
//...
}
class FileUploadList extends React.Component {
constructor(props) {
super(props)
this.state = {
files: props.files || [],
uploads: [],
}
}
//...
}
This causes a problem in xpub-submit
's SubmitPage
component, which uses redux-form
to populate form inputs. redux-form
(at least by default) populates input components by setting their value
prop. The result is that the list of supplementary files in the submission form is always empty.
If you upload a file, there's a brief flicker of an entry in the list, presumably after the FileUploadList
component calls setState
on itself, but it disappears, presumably because the component's been re-rendered/replaced.
I don't know if the convention of using value
to populate a form input component is a strong one, but it seems to me like hewing to it (i.e. renaming the files
prop back to value
) is the correct solution here. Thoughts?