React-Autocomplete without the tears
npm install @dccs/react-filepicker-muistring[] | Array of Ids from selected files |
(newValue: string[]) => void | gets called every time a file is: (file: File) => Promise | do something with the file and return an Id for it |
(id: string) => Promise | gets called for every Id in the value[] and should return the metadata for the file with the given Id |
javascript
value={fileIds}
onChange={ids => {
setFileIds(ids);
}}
uploadFile={(file:File)=>{
// could look like this:
string fileId = await api.uploadFile(file);
return fileId;
}}
getFile={(id: string) => {
// could look like this:
let metadata = await api.getFile(id);
return metadata;
}}
/>
`
$3
`javascript
value={fileIds}
onChange={ids => {
setFileIds(ids);
}}
uploadFile={(file:File)=>{
// could look like this:
string fileId = await api.uploadFile(file);
return fileId;
}}
getFile={(id: string) => {
// could look like this:
let metadata = await api.getFile(id);
return metadata;
}}
>
{(state, files, removeFile) => (
{...state.getRootProps()}
style={{ minWIdth: 500, minHeight: 500, backgroundColor: "gray" }}
>
{files.map(f => (
onClick={e => {
e.stopPropagation();
removeFile(f.id);
}}
>
Delete
))}