Skip to content

Commit 23792c9

Browse files
author
Ostap Chervak
committed
fix(router): Incorrect values passed to route context
1 parent 1c780ed commit 23792c9

File tree

3 files changed

+15
-4
lines changed

3 files changed

+15
-4
lines changed

examples/simple-ts/pages/root.page.tsx

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import * as React from 'react';
2-
import { Link, Translator, Component, observable, i18n } from '../../../src/poa';
2+
import { Link, Translator, Component, observable, i18n, Route } from '../../../src/poa';
33

4-
import { Store, Actions } from '../store';
4+
import { Store, Actions, RouterHookOpts } from '../store';
55

66
@Component({ namespaces: ['common', 'pages'] })
77
export class RootPage extends React.Component {
@@ -11,6 +11,16 @@ export class RootPage extends React.Component {
1111

1212
@observable localState = { newHello: '' };
1313

14+
static canActivate(route: Route) {
15+
const { store }: RouterHookOpts = route.context;
16+
17+
if (!store.helloText) {
18+
return false;
19+
}
20+
21+
return true;
22+
}
23+
1424
render() {
1525
return (
1626
<React.Fragment>

examples/simple-ts/store/index.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,3 +6,4 @@ export type Actions = typeof actions;
66

77
export type MutationOpts = { store: Store };
88
export type SideEffectOpts = { store: Store; actions: Actions };
9+
export type RouterHookOpts = { store: Store; actions: Actions };

src/poa.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,8 +39,6 @@ export async function boot(config: PoaBootConfig) {
3939
await reactDomPromisify(<config.react.loadingComponent />, config.react.htmlNode);
4040
}
4141

42-
const { router } = await bootRouter(config);
43-
4442
await bootstrapLocalization(config.i18n || {});
4543

4644
if (config.state) {
@@ -51,6 +49,8 @@ export async function boot(config: PoaBootConfig) {
5149
await bootstrapState({}, [], config.env);
5250
}
5351

52+
const { router } = await bootRouter(config);
53+
5454
await reactDomPromisify(
5555
<PoaApp config={config} router={router} />,
5656

0 commit comments

Comments
 (0)