Background
I am attempting to set a variable based on two separate button-groups using onClick() to update the useState.
The first group will record either "data1", "data2", or "data3".
The second group will record "0", "1", or "3".
I am looking for the end result to be a variable which I can use to select which group of data to pull.
The variable should look something like this "data10". (where button 1 was selected in both groups.)
Current code
const [bigChartData, setbigChartData] = React.useState("data1");
const setBgChartData = (name) => {
setbigChartData(name);
(name+bigChartTime);
};
const [bigChartTime, setbigChartTime] = React.useState("0");
const setBgChartTime = (name) => {
setbigChartTime(name);
console.log(bigChartData+(name));
};
Further down the code the following presents the dynamic data
<div className="chart-area">
<Line
data={chartExample1[bigChartData]}
options={chartExample1.options}
/>
</div>
The Problem
I receive the following error
Expected an assignment or function call and instead saw an expression no-unused-expressions
I understand that this is telling me I can't use an expression here, but I am little lost for how to otherwise build this
What I've tried
- Set the
{}around this but it still gives the same error. - Set the
()around this but it still gives the same error. - Using
console.log(name+bigChartTime);in place of line 4, it presents the information I expect to the console without an error.
If there is anyway to workaround this or if I need to rework in a different way, all help is appreciated!