Skip to content

Commit

Permalink
refactor(core): move scrollContext to singletons
Browse files Browse the repository at this point in the history
  • Loading branch information
binoy14 committed Apr 29, 2024
1 parent 30cc592 commit 5ca1b00
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 5 deletions.
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
import {type PubSub} from 'nano-pubsub'
import type {PubSub} from 'nano-pubsub'
import {createContext} from 'react'

/**
* @internal
*/
export const ScrollContext = createContext<null | PubSub<Event>>(null)
1 change: 1 addition & 0 deletions packages/sanity/src/_singletons/index.ts
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
export * from './changeIndicators/ConnectorContext'
export * from './components/previewCard/PreviewCardContext'
export * from './components/scroll/scrollContext'
3 changes: 1 addition & 2 deletions packages/sanity/src/core/components/scroll/hooks.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import {type Subscriber} from 'nano-pubsub'
import {useContext, useEffect} from 'react'

import {ScrollContext} from './scrollContext'
import {ScrollContext} from 'sanity/_singletons'

/** @internal */
export function useOnScroll(callback: Subscriber<Event>) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,7 @@ import {
useEffect,
useMemo,
} from 'react'

import {ScrollContext} from './scrollContext'
import {ScrollContext} from 'sanity/_singletons'

/** @internal */
export interface ScrollContainerProps<T extends ElementType>
Expand Down

0 comments on commit 5ca1b00

Please sign in to comment.