-
I am trying to achieve the same functionality as the Your example const [selectedId, setSelectedId] = useState(null)
{items.map(item => (
<motion.div layoutId={item.id} onClick={() => setSelectedId(item.id)}>
<motion.h5>{item.subtitle}</motion.h5>
<motion.h2>{item.title}</motion.h2>
</motion.div>
))}
<AnimatePresence>
{selectedId && (
<motion.div layoutId={selectedId}>
<motion.h5>{item.subtitle}</motion.h5>
<motion.h2>{item.title}</motion.h2>
<motion.button onClick={() => setSelectedId(null)} />
</motion.div>
)}
</AnimatePresence> |
Beta Was this translation helpful? Give feedback.
Answered by
emrecoban
Apr 19, 2023
Replies: 1 comment
-
I forgot |
Beta Was this translation helpful? Give feedback.
0 replies
Answer selected by
emrecoban
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
I forgot
layoutId
prop, sorry. It is resolved.