Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 8 additions & 6 deletions components/application/carousel/carousel-base.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -109,12 +109,8 @@ const CarouselRoot = ({ orientation = "horizontal", opts, setApi, plugins, class
[scrollPrev, scrollNext],
);

useEffect(() => {
if (!api || !setApi) return;

setApi(api);
}, [api, setApi]);

// Subscribe before handing the api to setApi: effects run in order, so a consumer that
// scrolls as soon as it gets the api must find these listeners already attached.
useEffect(() => {
if (!api) return;

Expand All @@ -129,6 +125,12 @@ const CarouselRoot = ({ orientation = "horizontal", opts, setApi, plugins, class
};
}, [api, onInit, onSelect]);

useEffect(() => {
if (!api || !setApi) return;

setApi(api);
}, [api, setApi]);

return (
<CarouselContext.Provider
value={{
Expand Down
Loading