I have a button which has a value that changes based on State. One of the instances combines a string and a Fontawesome object into an array. I get the key warning on render, however, I have no idea how to set the key on value.
Below I've included a snippet of the relevant code to illustrate what I'm doing. There are no loop wrapped around the code, which is where I've seen the key requirement previously.
The code actually works fine, switching the value in the button field, however, I get the annoying warning in the console.
The error is "Warning: Each child in a list should have a unique "key" prop."
const [ saveBtTxt, setSaveBtText ] = useState(["Save Filter"]);
const saveFilter = (e) => {
if(showFilterField) {
setSaveBtText(["Saved ",<FontAwesomeIcon icon={["far","check"]} />])
}
setFilterField(true);
}
return (
<Button className="outline" label={saveBtTxt} clickHandler={saveFilter} />
)