Home > Net >  Move component in a div to another div when clicked in react
Move component in a div to another div when clicked in react

Time:04-19

Let's say I have one component that only holds an image and two divs, one holding the componenet, laid out as such:

enter image description here

Upon being clicked, the component will move into the other div enter image description here

Then when the component is clicked again, it moves back to its original spot, like such: enter image description here

What would the logic be in order to accomplish this? Any help would be appreciated especially with code examples.

CodePudding user response:

You can refer to my codesandbox link: https://codesandbox.io/embed/magical-minsky-bx681m?fontsize=14&hidenavigation=1&theme=dark

  • Related