-
-
Notifications
You must be signed in to change notification settings - Fork 231
New issue
Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? # to your account
Redirects not working as expected #100
Comments
Ah that's not going to work. In this bit here: button(onClick --> {println("Logging in"); AuthenticationStore.authenticated = true; redirect(pvt, Replace)})("Login") you're calling You need to redirect like you normally would outside the |
To be clear, something like this: button(onClick --> {println("Logging out"); AuthenticationStore.authenticated = false; ic.router.setIO(root).unsafePerformIO() })("Logout") |
also, I don't think it will work because even though you are redirecting the route, you still return the component for the current route. So you probably need to replace |
The redirect is an action that's triggered when the user clicks a button
which seems fine. It would be different if he were performing the redirect
on interceptRender but one should never do that anyway. That would be bad,
a hack.
|
@japgolly Oh right! I miss that part. |
Works after implementing @japgolly suggestion. Thanks! |
I've used @japgolly implementation, but i've got an error: Uncaught Error: Invariant Violation: removeComponentAsRefFrom(...): Only a ReactOwner can have refs. This usually means that you're trying to remove a ref to a component that doesn't have an owner (that is, was not created inside of another component's Does someone have the same error? |
I'm sorry, i've solved it |
Context: https://gitter.im/japgolly/scalajs-react?at=5524ad269f817500153c209b
To produce a minimized example that shows a problem with
interceptRender
and redirect, I tried the following code (the original project uses Flux and all that, so a bit complex to explain). But redirect isn't working for me. Is my use of redirect correct or does this show an issue with scalajs-react?I expected that when I click on the Login button, it should show the private page content and the url to be
/private
. But I don't see any change.The text was updated successfully, but these errors were encountered: