Skip to content

Commit

Permalink
initialRouteName --> root
Browse files Browse the repository at this point in the history
  • Loading branch information
kanzitelli committed Mar 18, 2023
1 parent 089fead commit ae253de
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 9 deletions.
16 changes: 8 additions & 8 deletions src/navio.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -972,19 +972,19 @@ export class Navio<
* Generates `<Root />` component for provided layout. Returns Stack Navigator.
*/
private Root: React.FC<RootProps<TRootName<StacksName, TabsName, DrawersName>>> = ({
initialRouteName,
root: parentRoot,
}) => {
const {stacks, tabs, modals, drawers, root} = this.layout;
const appRoot = initialRouteName ?? root;
const appRoot = parentRoot ?? root;
const AppStack = createNativeStackNavigator();

// Effects
useEffect(() => {
// -- changing route if `initialRouteName` was changed
if (initialRouteName) {
this.__setRoot(initialRouteName);
// -- changing route if `root` was changed
if (parentRoot) {
this.__setRoot(parentRoot);
}
}, [initialRouteName]);
}, [parentRoot]);

// UI Methods
// -- app stacks
Expand Down Expand Up @@ -1055,7 +1055,7 @@ export class Navio<
*/
App: React.FC<RootProps<TRootName<StacksName, TabsName, DrawersName>>> = ({
navigationContainerProps,
initialRouteName,
root: parentRoot,
}) => {
// Navigation-related methods
const _navContainerRef = (instance: NavigationContainerRef<{}> | null) => {
Expand All @@ -1076,7 +1076,7 @@ export class Navio<
ref={_navContainerRef}
onReady={_navContainerOnReady}
>
<this.Root initialRouteName={initialRouteName} />
<this.Root root={parentRoot} />
</NavigationContainer>
);
};
Expand Down
2 changes: 1 addition & 1 deletion src/types.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -155,7 +155,7 @@ export type NavioScreen<Props = {}> = React.FC<PropsWithChildren<Props>> & {
// Layouts
export type RootProps<RootName extends string> = {
navigationContainerProps?: Omit<ExtractProps<typeof NavigationContainer>, 'children'>;
initialRouteName?: RootName;
root?: RootName;
};

// Tunnel (Event Emitter)
Expand Down

0 comments on commit ae253de

Please sign in to comment.