-1
Hello,
I’m running a simple application on Reactjs. I created some check buttons, which when clicked changes color, but I press these buttons on a map and when I click to change the color of one, changes all.
After clicking any button, all are selected.
This is the map function that creates the buttons:
{botoes.map((title, i) => (
<GridLabel key={i}>
{check ? (
<FaCheckCircle
onClick={handleUnchecked}
size={24}
color="#000"
style={{ cursor: 'pointer' }}
/>
) : (
<FaRegCheckCircle
onClick={handleCheck}
size={24}
color="#000"
style={{ cursor: 'pointer' }}
/>
)}
</GridLabel>
))}
I created a function to change the state to true, where it changes the color of the button and another to return to false, where the button goes back to the initial state.
const [check, setCheck] = useState(false);
function handleCheck(e) {
e.preventDefault();
setCheck(true);
}
function handleUnchecked(e) {
e.preventDefault();
setCheck(false);
}
From what I’ve researched, I need to store the button being clicked, but I can’t find a way to accomplish this.
how you upload this list or are independent boxes ???
– novic