@lucasbordeau @charlesBochet Issue #4826 Could u review this changes. Let me know what do you think. --------- Co-authored-by: Lucas Bordeau <bordeau.lucas@gmail.com>
23 lines
657 B
TypeScript
23 lines
657 B
TypeScript
import { useContext } from 'react';
|
|
|
|
import { isUndefinedOrNull } from '~/utils/isUndefinedOrNull';
|
|
|
|
import {
|
|
ContextProviderName,
|
|
getContextByProviderName,
|
|
} from '@/ui/utilities/scroll/contexts/ScrollWrapperContexts';
|
|
|
|
export const useScrollWrapperScopedRef = (
|
|
contextProviderName: ContextProviderName,
|
|
) => {
|
|
const Context = getContextByProviderName(contextProviderName);
|
|
const scrollWrapperRef = useContext(Context);
|
|
|
|
if (isUndefinedOrNull(scrollWrapperRef))
|
|
throw new Error(
|
|
`Using a scroll ref without a ScrollWrapper : verify that you are using a ScrollWrapper if you intended to do so.`,
|
|
);
|
|
|
|
return scrollWrapperRef;
|
|
};
|