redux store created AFTER router match while doing server-side rendering in ReactReduxSpa #1034

Closed
opened 2025-08-09 17:18:37 +00:00 by fergalmoran · 0 comments
Owner

Originally created by @HaraldMuehlhoffCC on 2/11/2017

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

*Originally created by @HaraldMuehlhoffCC on 2/11/2017* 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](https://github.com/aspnet/JavaScriptServices/blob/dev/templates/ReactReduxSpa/ClientApp/boot-server.tsx)
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: github/JavaScriptServices#1034
No description provided.