-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
#182 Only log missing context warning in public API
- Loading branch information
1 parent
28e11e1
commit 4fcc059
Showing
4 changed files
with
36 additions
and
20 deletions.
There are no files selected for viewing
13 changes: 1 addition & 12 deletions
13
packages/react-transition-presence/src/TransitionPresence/TransitionPresence.context.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,17 +1,6 @@ | ||
import { createContext, useContext, type RefObject } from 'react'; | ||
import { createContext, type RefObject } from 'react'; | ||
import type { BeforeUnmountCallback } from '../useBeforeUnmount/useBeforeUnmount.js'; | ||
|
||
export type TransitionPresenceContextType = Set<RefObject<BeforeUnmountCallback>> | undefined; | ||
|
||
export const TransitionPresenceContext = createContext<TransitionPresenceContextType>(undefined); | ||
|
||
export function useTransitionPresence(): TransitionPresenceContextType { | ||
const context = useContext(TransitionPresenceContext); | ||
|
||
if (context === undefined) { | ||
// eslint-disable-next-line no-console | ||
console.warn('Component is not rendered in the context of a TransitionPresence'); | ||
} | ||
|
||
return context; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,6 @@ | ||
export * from './TransitionPresence/TransitionPresence.js'; | ||
export * from './TransitionPresence/TransitionPresence.context.js'; | ||
export * from './useBeforeUnmount/useBeforeUnmount.js'; | ||
export { TransitionPresenceContext } from './TransitionPresence/TransitionPresence.context.js'; | ||
export { TransitionPresence } from './TransitionPresence/TransitionPresence.js'; | ||
export { | ||
type BeforeUnmountCallback, | ||
useBeforeUnmount, | ||
} from './useBeforeUnmount/useBeforeUnmount.js'; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters