I'm sure this is a simple question but I can't figure this out.
const [rowLabels, setRowLabels] = React.useState(['','','','','',]);
i figured this would work. but it doesn't like the syntax.
setRowLabels(oldValues => ([
...oldValues,
oldValues[position]: event.target.value
])
I know I can do this below, but I rather not pass down rowLabels as props to avoid the re-render. Is there a way I can do it with just the oldValues?
const rowLabelsCopy = [...rowLabels];
rowLabelsCopy[position] = event.target.value;
setRowLabels(rowLabelsCopy);