react-csv-importer
react-csv-importer copied to clipboard
Dynamically generated ImportFields are not cleaned. No option to rerender Importer
Hey, I have a usecase where user can select from multiple ImporterField configurations using select input. After selection an array with fields for mapping is created: eg.
table1 = ['a','b']
table2 = ['c', 'd']
const [importColumns, setImportColumns] = useState([])
importColumns is set using select input
inside Importer it should be dynamically rendered like this
<Importer {...props} >
{importColumns.map((field, i) => (
<ImporterField key={i} name={field} label={field} />
))}
</Importer>
Problem is that when user changes select, Importer will concatenate all columns config and it will have all like ['a', 'b', 'c', 'd'] instead of rendering only those that are selected. There is no option to re-render Importer after selection is made. Only option is to refresh browser and re-render entire app.
Oh, that's a good catch, thanks. I'll add this to my to-do list (fixes have been really slow for me the last while but I am working through the pile).
Hi Rafal, this should be now fixed in v0.8.0.