Skip to content

Commit 1bf2afb

Browse files
authored
feat: add onReady and onStateChange callbacks (#608)
* feat: add `onReady` and `onStateChange` callbacks to `InjectedNavigationContainer` * fix: export `getActiveLeafRoute` * fix: add `state` to `onStateChange` * chore: remove duplicate export
1 parent 3f6cfa0 commit 1bf2afb

File tree

2 files changed

+17
-6
lines changed

2 files changed

+17
-6
lines changed

src/Containers/InjectedNavigationContainer.tsx

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ import {
1212
createNavigationContainerRef,
1313
DefaultTheme,
1414
DarkTheme,
15+
type NavigationState,
1516
} from '@react-navigation/native'
1617
import { useFlipper } from '@react-navigation/devtools'
1718

@@ -25,13 +26,21 @@ import { registerOnActionFactory } from './ReactNavigationInjection'
2526

2627
type Props = {
2728
children: React.ReactNode,
28-
isDarkThemeEnabled: boolean,
2929
getContext: () => ResolveConditionContext,
30+
isDarkThemeEnabled: boolean,
31+
onReady?: () => void,
32+
onStateChange?: (state: NavigationState | undefined) => void,
3033
}
3134

3235
export const navigationRef = createNavigationContainerRef()
3336

34-
export const InjectedNavigationContainer = ({ children, isDarkThemeEnabled, getContext }: Props): JSX.Element => {
37+
export const InjectedNavigationContainer = ({
38+
children,
39+
getContext,
40+
isDarkThemeEnabled,
41+
onReady,
42+
onStateChange,
43+
}: Props): JSX.Element => {
3544
useFlipper(navigationRef)
3645
useAndroidBackNavigation(navigationRef)
3746

@@ -43,6 +52,8 @@ export const InjectedNavigationContainer = ({ children, isDarkThemeEnabled, getC
4352
<NavigationContainer
4453
ref={navigationRef}
4554
theme={isDarkThemeEnabled ? DarkTheme : DefaultTheme}
55+
onReady={onReady}
56+
onStateChange={onStateChange}
4657
>
4758
{children}
4859
</NavigationContainer>

src/index.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,6 @@ export {
99
registerScreenConditions,
1010
screenConditionConfigMap,
1111
} from './Api/ConditionManager'
12-
export {
13-
getActiveLeafRoute,
14-
} from './Api/NavigationUtils'
1512
export { configManager } from './Config'
1613
export { registerOnActionFactory } from './Containers/ReactNavigationInjection'
1714
export {
@@ -62,7 +59,10 @@ export {
6259
conditionalNavigationManager,
6360
registerResolveCondition,
6461
} from './Api/ConditionalNavigationManager'
65-
export { calculateStaticTreeDepth } from './Api/NavigationUtils'
62+
export {
63+
calculateStaticTreeDepth,
64+
getActiveLeafRoute,
65+
} from './Api/NavigationUtils'
6666
export { useIsInitial } from './Hooks/UseIsInitial'
6767
export {
6868
type Navigation,

0 commit comments

Comments
 (0)