Multiple carousels and refs? #201
-
Hey there! I'm running into a problem I'm a little stuck trying to solve. I have an object consisting of keys with arrays of images as the values. Each key I'm trying to render as a new carousel, using chakra-uis TabList component (So the carousel is being unmounted, and remounted on tab change). I can't seem to get the embla carousel to reinit on tab change, the ref stays attached to the initial slider. Any guidance here would be appreciated!
|
Beta Was this translation helpful? Give feedback.
Replies: 2 comments
-
Of course, as soon as I post this I figure out the problem. I changed the Tabs component to lazy mount and unrender the component on tab change. |
Beta Was this translation helpful? Give feedback.
-
Hi @jacobgranberry, You can manually trigger a useEffect(() => {
if (!embla) return
embla.reInit()
}, [embla, tabKey]) Just make sure the |
Beta Was this translation helpful? Give feedback.
Of course, as soon as I post this I figure out the problem. I changed the Tabs component to lazy mount and unrender the component on tab change.