I'm trying to use file upload data and as soon as file dropped the data should be contained in state
So this is the code that make an error :
const handleOnDrop = data => {
const infos = data.map(item => item.data);
setTimeout(() => setInfo([...infos]), 1000);
};
And I tried to fix it with this :
const handleOnDrop = async data => {
const infos = data.map(item => item.data);
await setTimeout(() => setInfo([...infos]), 1000);
};
However, I still got the same error :
index.js:1 Warning: Can't perform a React state update on an unmounted component. This is a no-op, but it indicates a memory leak in your application. To fix, cancel all subscriptions and asynchronous tasks in the componentWillUnmount method.
And this is the way I use it :
<CSVReader
onDrop={handleOnDrop}
onError={handleOnError}
style={{}}
config={
(({ fastMode: true }, { chunk: "LocalChunkSize" }),
{ header: false })
}
addRemoveButton
onRemoveFile={handleOnRemoveFile}
>
I use it from papaprse, but I can't figure it why it happens. I want to know how I can fix this issue, and I want to know why it happens.