I have two buttons accept and reject buttons, that are part of a card which is generated from a map function. I need to enable each of the cards states and set to loading independently. This is how I am currently activating the state to busy:
const [isBusy, setBusy] = useState({});
........
setBusy(prev => ({ ...prev, [id]: true }));
setTimeout(
() => setBusy(prev => ({ ...prev, [id]: false })),
3000
);
These are the buttons
return [
<Button loading={isBusy[id] || false} title="Invite" onPress={() => invite(id)} />,
<Button loading={isBusy[id] || false} title="Remove" onPress={() => reject(id)} />,
];
The challenge at the moment, is clicking on Invite button activates also the state of remove button in that particular card that matches the id.
This is all contained in a card displayed under a map function, each card has two buttons to be displayed, invite and reject button respectively, I need to handle the sate of these individual buttons within each card separately, so that if I click invite, isBusy is activated only for invite button and reject button is handled as separate too