I’ve placed the following buttons within a div
const [state, setstate] = useState([]);
const arr = [1,2,3,4,5];
return arr.map((num) => {
return (
<button
key={num}
className="buttons"
onClick={(e) => {
state.push(num);
}}
>
{num}
</button>
);
When those buttons are clicked, I want them to move to another div. And when the button is clicked on the other div, the button has to come back to the original div.I found a solution but it involves document.getElementById(). But I believe that it is not a good thing to do in reactjs. Any ideas?