You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 

25 lines
859 B

import { createContext, useContext, type ReactNode, type RefObject } from 'react'
const PrimaryPageScrollAreaRefContext = createContext<RefObject<HTMLDivElement | null> | null>(null)
/**
* The desktop primary column’s main `overflow-y: auto` node (see {@link PrimaryPageLayout}).
* Feeds use this so {@link VirtualizedFeedRows} observes the same scrollport the user actually scrolls.
*/
export function PrimaryPageScrollAreaRefProvider({
scrollAreaRef,
children
}: {
scrollAreaRef: RefObject<HTMLDivElement | null>
children: ReactNode
}) {
return (
<PrimaryPageScrollAreaRefContext.Provider value={scrollAreaRef}>
{children}
</PrimaryPageScrollAreaRefContext.Provider>
)
}
export function usePrimaryPageScrollAreaRefOptional(): RefObject<HTMLDivElement | null> | null {
return useContext(PrimaryPageScrollAreaRefContext)
}