#ScrollArea with scrollIntoView hook

8 messages · Page 1 of 1 (latest)

formal sonnet
#

Hello guys, im trying to use useScrollIntoView hook to scroll to certain area. That area are in a ScrollArea componente, but when i click to scroll to some view nothing happens.
If i change scrollArea to some normal <div> with scroll everything works. Any problem related with ScrollArea and scrollIntoView hook?

lofty quarry
formal sonnet
#

But how can a scroll to a "section" inside of a scrollArea? viewportRef is only available for scrollArea component right?

lofty quarry
formal sonnet
#

Yep thats it! Thanks

#

One more thing, it is possible to have multiple targets? Like for different sections in scrollArea?

lofty quarry
#

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