UNPKG

mobx-react-routing

Version:
20 lines (19 loc) 583 B
import { ViewModelBase } from 'mobx-view-model'; export class PageViewModelBase extends ViewModelBase { router; routeDeclaration; constructor(routeDeclaration, router, config) { super(config); this.routeDeclaration = routeDeclaration; this.router = router; } get routeMatch() { return (this.router.matches.find((match) => match.id === this.routeDeclaration.id) ?? null); } get pathParams() { return (this.routeMatch?.params ?? {}); } get queryParams() { return this.router.queryParams.data; } }