Getting this error:
Uncaught TypeError: Data should be a "String", "Array of arrays" OR "Array of objects"
when I'm providing a function to CSVLink data attribute following "Async + data function" example.
Here is my code:
const [exportData, setExportData] = useState([]);
const fetchExportedData = (event: any, done: any) => {
axios
.get(baseRoute + '?export=1', {
withCredentials: true,
headers: { 'Content-Type': 'application/json' },
})
.then((response) => {
if (response.status === 200) {
setExportData(response.data);
done(true);
} else {
done(false);
}
});
};
const getExportedData = (): Array<any> => {
return exportData;
}
<CSVLink
data={getExportedData}
asyncOnClick={true}
onClick={fetchExportedData}
filename='data.csv'
>
Export Data
</CSVLink>
Getting this error:
Uncaught TypeError: Data should be a "String", "Array of arrays" OR "Array of objects"when I'm providing a function to CSVLink data attribute following "Async + data function" example.
Here is my code: