Usage with React Router
Prerequisite
npm install --save history react-router-domimport { createBrowserHistory } from 'history'
import { Store } from 'deviation'
export class RouterService extends Store {
history = createBrowserHistory()
}import { Router, Route } from 'react-router-dom'
import { Inject } from 'deviation'
export interface IAppRouter {
serviceRouter: ServiceRouter
}
@Inject({
routerService: RouterService
})
export class AppRouter extends React.Component<IAppRouter> {
render() {
return (
<Router history={this.props.routerService.history}>
<Route path="/" exact component={HomePage} />
<Router path="/login" exact component={LoginPage} />
</Router>
)
}
}Last updated
Was this helpful?