function to export json data to csv
npm install converter-json-csvjs
downloadCSVFromJson(yourfile.csv, jsonCSV);
The function receives two parameters, the first one receives the name of the file, the second one will receive the data in JSON
`
$3
`js
import React, { useEffect } from 'react';
import downloadCSVFromJson from 'converter-json-csv';
`
`json
const fruits = [
{'apple': 50, 'watermelon': 120, 'pear': 250},
{'apple': 150, 'watermelon': 240, 'pear': 10},
{'apple': 170, 'watermelon': 182, 'pear': 19},
]
`
`js
export default function App(){
useEffect(() => {
downloadCSVFromJson('yourFile.csv', fruits);
},[]);
``