useLockScrolling

Important!
import useLockScrolling from "@kiwicom/orbit-components/lib/hooks/useLockScrolling";
const Component = (props: Props) => {
const scrollableElementRef = (useRef < HTMLElement) | (null > null);
// locks the scrolling only to ScrollableContainer
useLockScrolling(scollableElementRef);
return <ScrollableContainer ref={scrollableElementRef}>Hello world!</ScrollableContainer>;
};

Props

NameTypeDefaultDescription
ref{ current: HTMLElement \| null }Reference object of the scrollable container.
lockbooleantrueWhether to lock scrolling or not. This is useful for example if locking scrolling depends on a breakpoint.
dependenciesany[][]Dependencies that affect the value of ref.current, in case it’s not always assigned to the same HTML element.