Skip to content

Latest commit

 

History

History
48 lines (33 loc) · 1.3 KB

DEBUGGINGv3.md

File metadata and controls

48 lines (33 loc) · 1.3 KB

Debugging

Routes execute twice for hash routes

This occurs if normal and hash routes are same (E.g.: https://example.com/path/to/route#/path/to/route). Therefore, route listener executes twice for this scenario. To fix this you can either use e.hash flag or switch to hash routing.

route('#/path/to/route', () => { ... });

Silkrouter throws "Invalid route" error

Silkrouter validates route strings and support routes that are valid for URL. If route string is invalid, you might get "Invalid route" error.

Valid route

route('/valid/route', ...); // A valid route starts with '/'

Invalid route

route('invalidRoute', ...);

Trying to remove list routes removes all generic routes

List routes are generic routes.

route([ ... ], () => { ... });
// Is equivalent to
route((e) => {
    switch(e.route) { ... }
});

Silkrouter registers a generic route, and hence the only way you can remove a list route is by passing route handler.

unroute([...]); // This will unroute all generic routes
unroute([...], fn); // This will unroute the specific handler

Please note that list routing is experimental.


Edit: As of version 3.4.6 simply passing a list route will not remove generic routes. To remove a list route you need to pass the handler.