#ScrollArea with scrollIntoView hook
8 messages · Page 1 of 1 (latest)
Use viewportRef prop instead of ref
But how can a scroll to a "section" inside of a scrollArea? viewportRef is only available for scrollArea component right?
Try passing scrollableRef to viewportRef prop of ScrollArea component
https://mantine.dev/hooks/use-scroll-into-view/#parent-node
viewportRef is only available for ScrollArea component
Yep thats it! Thanks
One more thing, it is possible to have multiple targets? Like for different sections in scrollArea?
It seems that this is not supported
But you can try to do something like that
const { scrollableRef: ref1 } = useScrollIntoView();
const { scrollableRef: ref2 } = useScrollIntoView();
const scrollableRef = useMergedRef(ref1, ref2);
<ScrollArea viewportRef={scrollableRef}>
...
</ScrollArea>
And then you should have one scrollableRef and two different targetRef properties and scrollIntoView methods