I am trying to a input a number through input tag and after pressing the submit button the state has to update and the updated state is used here sankeyData.splice({ count });. and useState default value should be 3. I am getting Uncaught TypeError: FormData.set: 1 is not a valid argument count for any overload.. And the default state is also not recognizing. I dont know where i am doing wrong.
import React, { useState } from "react";
import Chart from "react-google-charts";
import { data } from "./csvjson";
// const sankeyData = [];
// var sank = [];
// var output = data.map(function (obj) {
// return Object.keys(obj).slice(1).map(function (key) {
// return obj[key];
// });
// });
const First = () => {
const [count, setCount] = useState(0);
console.log(count);
const onSubmit = (e) => {
e.preventDefault();
const formdata = new FormData();
console.log(formdata.set(count));
};
const sankeyData = [
["From", "To", "Weight"],
["since", "None", 23],
["gallery", "None", 2],
["turnofthetwentiethcentury", "None", 1],
["turn", "None", 45],
["likedis", "None", 1],
["profound", "Male", 1],
["Semblance", "None", 1],
["Africans", "Male", 2],
["Guided", "None", 1],
["Golinski", "None", 1],
["implosion", "Male", 1],
["Searchs", "None", 1],
["concerning", "Female", 1],
["families", "Male", 2],
];
sankeyData.splice({ count });
return (
<div>
<h2>React Simple Sankey Chart Example</h2>
<Chart
width={700}
height={"350px"}
chartType="Sankey"
loader={<div>Loading Chart</div>}
data={sankeyData}
rootProps={{ "data-testid": "1" }}
/>
<div>
<form noValidate onSubmit={onSubmit}>
<input value={setCount} />
<button type="submit">SUBMIT</button>
</form>
</div>
</div>
);
};
export default First;