jesse1983 / marko-router5

Flexible and powerful routing for MarkoJS
https://jesse1983.github.io/marko-router5
MIT License
29 stars 4 forks source link

Cannot read property 'match' of undefined #1

Closed hedefalk closed 6 years ago

hedefalk commented 6 years ago

Hi! Awesome to see this project!

I keep getting these errors for path of '/'

path-parser.js:282 Uncaught TypeError: Cannot read property 'match' of undefined
    at Path../node_modules/path-parser/dist/es/path-parser.js.Path.urlTest (path-parser.js:282)
    at Path../node_modules/path-parser/dist/es/path-parser.js.Path.test (path-parser.js:170)
    at _loop_1 (route-node.js:131)
    at matchChildren (route-node.js:192)
    at RouteNode../node_modules/route-node/dist/es/route-node.js.RouteNode.getSegmentsMatchingPath (route-node.js:474)
    at RouteNode../node_modules/route-node/dist/es/route-node.js.RouteNode.matchPath (route-node.js:372)
    at Object.matchPath (utils.js:133)
    at Component.onMount (component.js:29)
    at emitLifecycleEvent (util-browser.js:46)
    at Component.___emitLifecycleEvent (Component.js:481)

It seems to be due to options.initialRoute being undefined after a few iterations:

image

hedefalk commented 6 years ago

Hm, just setting initialRoute to the same as defaultRoute I'm fine:

router routes=routes options={ defaultRoute: 'home', initialRoute: 'home' }

hedefalk commented 6 years ago

Ok, I can close this too I guess since I now understand what initialRoute is :)