mefechoel / svelte-navigator

Simple, accessible routing for Svelte
Other
504 stars 39 forks source link

May be something incorrect in the private route example #8

Closed mmrath closed 4 years ago

mmrath commented 4 years ago

Describe the bug I was looking at the private-routes example. Once you start the serve and navigate to http://localhost:<port>/profile, it does not render the login page, event though the url changes to http://localhost:<port>/login.

I moved code in PrivateRouteGaurd to onMount that appeared to work. But I am not sure if that is correct.

    onMount(checkUser);
    function checkUser() {
        if (!$user) {
            navigate("/login", {
                state: { from: $location.pathname },
                replace: true,
            });
        }
    }

To Reproduce Steps to reproduce the behavior:

  1. Go to http://localhost:<port>/profile once you start private-routes example
mefechoel commented 4 years ago

Hey @mmrath, I cannot reproduce the bug. I've tried the example in firefox and chrome and it works as expected. Did you modify the example in any other way?

mmrath commented 4 years ago

@mefechoel I tried it again just now and it worked. Sorry for the noise, I must have done something wrong.

Thanks for your work on this.