Skip to content
This repository has been archived by the owner on Feb 8, 2020. It is now read-only.

Commit

Permalink
fix: names of routers
Browse files Browse the repository at this point in the history
  • Loading branch information
osdnk committed Jul 23, 2019
1 parent e81116a commit 6637ae0
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 14 deletions.
14 changes: 7 additions & 7 deletions example/StackNavigator.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -69,8 +69,8 @@ export type StackNavigationProp<
popToTop(): void;
};

function CurrentRouter(options: DefaultRouterOptions) {
const StackRouter: Router<NavigationState, CommonAction | Action> = {
function StackRouter(options: DefaultRouterOptions) {
const router: Router<NavigationState, CommonAction | Action> = {
...BaseRouter,

getInitialState({ routeNames, routeParamList }) {
Expand Down Expand Up @@ -163,7 +163,7 @@ function CurrentRouter(options: DefaultRouterOptions) {
return null;

case 'POP_TO_TOP':
return StackRouter.getStateForAction(state, {
return router.getStateForAction(state, {
type: 'POP',
payload: { count: state.routes.length - 1 },
});
Expand Down Expand Up @@ -199,7 +199,7 @@ function CurrentRouter(options: DefaultRouterOptions) {
}

if (index === -1 && action.payload.name !== undefined) {
return StackRouter.getStateForAction(state, {
return router.getStateForAction(state, {
type: 'PUSH',
payload: {
name: action.payload.name,
Expand Down Expand Up @@ -228,7 +228,7 @@ function CurrentRouter(options: DefaultRouterOptions) {
return null;

case 'GO_BACK':
return StackRouter.getStateForAction(state, {
return router.getStateForAction(state, {
type: 'POP',
payload: { count: 1 },
});
Expand All @@ -250,14 +250,14 @@ function CurrentRouter(options: DefaultRouterOptions) {
},
},
};
return StackRouter;
return router;
}

export function StackNavigator(props: Props) {
const { state, descriptors } = useNavigationBuilder<
NavigationState,
StackNavigationOptions
>(CurrentRouter, props);
>(StackRouter, props);

return (
<div style={{ position: 'relative' }}>
Expand Down
8 changes: 4 additions & 4 deletions example/TabNavigator.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -53,8 +53,8 @@ export type TabNavigationProp<
): void;
};

function CurrentRouter(options: DefaultRouterOptions) {
const TabRouter: Router<NavigationState, Action | CommonAction> = {
function TabRouter(options: DefaultRouterOptions) {
const router: Router<NavigationState, Action | CommonAction> = {
...BaseRouter,

getInitialState({ routeNames, routeParamList }) {
Expand Down Expand Up @@ -174,14 +174,14 @@ function CurrentRouter(options: DefaultRouterOptions) {
},
},
};
return TabRouter;
return router;
}

export function TabNavigator(props: Props) {
const { state, descriptors } = useNavigationBuilder<
NavigationState,
TabNavigationOptions
>(CurrentRouter, props);
>(TabRouter, props);

return (
<div style={{ display: 'flex', flexDirection: 'row', height: '100%' }}>
Expand Down
6 changes: 3 additions & 3 deletions src/__tests__/__fixtures__/MockRouter.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@ export type MockActions = CommonAction & {

export const MockRouterKey = { current: 0 };

export default function CurrentRouter(options: DefaultRouterOptions) {
const MockRouter: Router<NavigationState, MockActions> = {
export default function MockRouter(options: DefaultRouterOptions) {
const router: Router<NavigationState, MockActions> = {
getInitialState({ routeNames, routeParamList }) {
const index =
options.initialRouteName === undefined
Expand Down Expand Up @@ -84,5 +84,5 @@ export default function CurrentRouter(options: DefaultRouterOptions) {
actionCreators: {},
};

return MockRouter;
return router;
}

0 comments on commit 6637ae0

Please sign in to comment.