Skip to content

Commit

Permalink
fix(router): Incorrect values passed to route context
Browse files Browse the repository at this point in the history
  • Loading branch information
Ostap Chervak committed Jan 3, 2018
1 parent 1c780ed commit 23792c9
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 4 deletions.
14 changes: 12 additions & 2 deletions examples/simple-ts/pages/root.page.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import * as React from 'react';
import { Link, Translator, Component, observable, i18n } from '../../../src/poa';
import { Link, Translator, Component, observable, i18n, Route } from '../../../src/poa';

import { Store, Actions } from '../store';
import { Store, Actions, RouterHookOpts } from '../store';

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

@observable localState = { newHello: '' };

static canActivate(route: Route) {
const { store }: RouterHookOpts = route.context;

if (!store.helloText) {
return false;
}

return true;
}

render() {
return (
<React.Fragment>
Expand Down
1 change: 1 addition & 0 deletions examples/simple-ts/store/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,3 +6,4 @@ export type Actions = typeof actions;

export type MutationOpts = { store: Store };
export type SideEffectOpts = { store: Store; actions: Actions };
export type RouterHookOpts = { store: Store; actions: Actions };
4 changes: 2 additions & 2 deletions src/poa.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,6 @@ export async function boot(config: PoaBootConfig) {
await reactDomPromisify(<config.react.loadingComponent />, config.react.htmlNode);
}

const { router } = await bootRouter(config);

await bootstrapLocalization(config.i18n || {});

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

const { router } = await bootRouter(config);

await reactDomPromisify(
<PoaApp config={config} router={router} />,

Expand Down

0 comments on commit 23792c9

Please sign in to comment.