[英]Move component in a div to another div when clicked in react
Let's say I have one component that only holds an image and two divs, one holding the compon.net, laid out as such:假设我有一个仅包含图像和两个 div 的组件,其中一个包含 compon.net,布局如下:
Upon being clicked, the component will move into the other div单击后,组件将移动到另一个 div
Then when the component is clicked again, it moves back to its original spot, like such:然后当再次点击该组件时,它会回到原来的位置,如下所示:
What would the logic be in order to accomplish this?为了实现这一点,逻辑是什么? Any help would be appreciated especially with code examples.
任何帮助将不胜感激,尤其是代码示例。
You can refer to my codesandbox link: https://codesandbox.io/embed/magical-minsky-bx681m?fontsize=14&hidenavigation=1&theme=dark可以参考我的codesandbox链接: https://codesandbox.io/embed/magical-minsky-bx681m?fontsize=14&hidenavigation=1&theme=dark
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.