[Help]: Why does Embla for React use methods? #1285
-
SummaryWhy does Embla Carousel in React use methods and not state to control the carousel? If applicable, which variants of Embla Carousel are relevant to this conversation?
Additional informationNo response CodeSandbox exampleNo response |
Beta Was this translation helpful? Give feedback.
Answered by
davidjerleke
Mar 27, 2026
Replies: 1 comment 2 replies
-
|
Hi, I’m not sure I understand what you’re asking. When you say “why does Embla for React use methods and not state”, do you mean:
|
Beta Was this translation helpful? Give feedback.
2 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
@Alvi24, thanks for clarifying.
There are quite a few benefits to controlling Embla via an API (like
emblaApi.scrollTo()) instead of relying on React state:It lets you granularly create only the state you actually need, instead of a component managing a large internal state for many features you might never use. This keeps things more lightweight and flexible.
Whenever the core package (embla-carousel) API changes, the React wrapper (and the Vue, Svelte, Solid versions) automatically get access to those updates. There’s no need to manually expose new state or remove old ones, which reduces maintenance overhead and avoids lag between packages and package releases.
It avoids unnecess…