const exportData = () => {
const jsonString = `data:text/json;chatset=utf-8,${encodeURIComponent(
JSON.stringify(data)
)}`;
const link = document.createElement("a");
link.href = jsonString;
link.download = "data.json";
link.click();
};
return (
<div className="App">
<h1>Hello CodeSandbox</h1>
<h2>Start editing to see some magic happen!</h2>
<button type="button" onClick={exportData}>
Export Data
</button>
</div>
);
}