Skip to content

Commit

Permalink
Use new context pattern
Browse files Browse the repository at this point in the history
  • Loading branch information
atomiks committed Oct 15, 2024
1 parent fa62cdf commit 021ae16
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -21,15 +21,17 @@ export interface ScrollAreaRootContext {
handlePointerUp: (event: React.PointerEvent) => void;
}

export const ScrollAreaRootContext = React.createContext<ScrollAreaRootContext | null>(null);
export const ScrollAreaRootContext = React.createContext<ScrollAreaRootContext | undefined>(
undefined,
);

if (process.env.NODE_ENV !== 'production') {
ScrollAreaRootContext.displayName = 'ScrollAreaRootContext';
}

export function useScrollAreaRootContext() {
const context = React.useContext(ScrollAreaRootContext);
if (context === null) {
if (context === undefined) {
throw new Error('Base UI: ScrollAreaRootContext is undefined.');
}
return context;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,17 +4,17 @@ export interface ScrollAreaScrollbarContext {
orientation: 'horizontal' | 'vertical';
}

export const ScrollAreaScrollbarContext = React.createContext<ScrollAreaScrollbarContext | null>(
null,
);
export const ScrollAreaScrollbarContext = React.createContext<
ScrollAreaScrollbarContext | undefined
>(undefined);

if (process.env.NODE_ENV !== 'production') {
ScrollAreaScrollbarContext.displayName = 'ScrollAreaScrollbarContext';
}

export function useScrollAreaScrollbarContext() {
const context = React.useContext(ScrollAreaScrollbarContext);
if (context === null) {
if (context === undefined) {
throw new Error('Base UI: ScrollAreaScrollbarContext is undefined.');
}
return context;
Expand Down

0 comments on commit 021ae16

Please sign in to comment.