Created a specific scroll wrapper context per scroll wrapper and made ScrollTop and ScrollLeft componentStates (#6645)
@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>
This commit is contained in:
@ -2,10 +2,16 @@ import { useContext } from 'react';
|
||||
|
||||
import { isUndefinedOrNull } from '~/utils/isUndefinedOrNull';
|
||||
|
||||
import { ScrollWrapperContext } from '../components/ScrollWrapper';
|
||||
import {
|
||||
ContextProviderName,
|
||||
getContextByProviderName,
|
||||
} from '@/ui/utilities/scroll/contexts/ScrollWrapperContexts';
|
||||
|
||||
export const useScrollWrapperScopedRef = () => {
|
||||
const scrollWrapperRef = useContext(ScrollWrapperContext);
|
||||
export const useScrollWrapperScopedRef = (
|
||||
contextProviderName: ContextProviderName,
|
||||
) => {
|
||||
const Context = getContextByProviderName(contextProviderName);
|
||||
const scrollWrapperRef = useContext(Context);
|
||||
|
||||
if (isUndefinedOrNull(scrollWrapperRef))
|
||||
throw new Error(
|
||||
|
||||
Reference in New Issue
Block a user