You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository was archived by the owner on Apr 8, 2020. It is now read-only.
Repository navigation
This repository was archived by the owner on Apr 8, 2020. It is now read-only.
redux store created AFTER router match while doing server-side rendering in ReactReduxSpa #663
I'm using onEnter in some Route elements that require authentication. On client-side things just worked; when rendered on server I got exceptions. As it turned out I was trying to access login-related info in the redux store in the function called by onEnter and it wasn't configured yet by boot-server.tsx. A simple issue to correct once I found it. To help other poor souls it might be a good idea to move the configureStore() call before the match in the template so client and server-side work the same.
Is the problem not that you're trying to run logic in a method that will only be executed on the client side?.
Would it not be better to put your auth logic in something like ComponentWillMount instead?
On 11 Feb 2017, at 11:36, Harald Mühlhoff ***@***.***> wrote:
I'm using onEnter in some Route elements that require authentication. On client-side things just worked; when rendered on server I got exceptions. As it turned out I was trying to access login-related info in the redux store in the function called by onEnter and it wasn't configured yet by boot-server.tsx. A simple issue to correct once I found it. To help other poor souls it might be a good idea to move the configureStore() call before the match in the template so client and server-side work the same.
https://github.com/aspnet/JavaScriptServices/blob/dev/templates/ReactReduxSpa/ClientApp/boot-server.tsx
—
You are receiving this because you are subscribed to this thread.
Reply to this email directly, view it on GitHub, or mute the thread.
@KraigWalker Thx for your comment. Actually the logic is executed also on the server-side ... and from what I understand about Route onEnter it's exactly the place to do things like authentication – and a redirect to login if not authorized (there are lot's of examples on the web). Once I moved the configureStore() in boot-server.tsx before the match things are working out as expected (redirectLocation is set and the login rendered)
Activity
KraigWalker commentedon Feb 11, 2017
HaraldMuehlhoffCC commentedon Feb 11, 2017
@KraigWalker Thx for your comment. Actually the logic is executed also on the server-side ... and from what I understand about Route
onEnterit's exactly the place to do things like authentication – and a redirect to login if not authorized (there are lot's of examples on the web). Once I moved theconfigureStore()inboot-server.tsxbefore thematchthings are working out as expected (redirectLocationis set and the login rendered)SteveSandersonMS commentedon Feb 21, 2017
Thanks for the suggestion. This change is now made and will be included next time the templates are published.