me-12 / single-spa-portal-example

Example project on how to combine multiple SPA's on a single Website
MIT License
407 stars 136 forks source link

Routing when using react-router-redux #31

Open yoanisgil opened 6 years ago

yoanisgil commented 6 years ago

I'm playing around with the single-spa-portal-example and while adapting my existing React app to be used with the portal example I ran into this routing issue where I have a few Redux actions that triggers a push action to get the user to a new page. Unfortunately push does not accept, by design I think, relative URLs, so all paths must be absolute. This is a bit disturbing since applications will need to know where they fit in the routing mechanism of the portal. I was just wondering if anyone has already stumble around this problem and what are some best practices to fix it?

I guess one could always pass down the path where the application is mounted and have actions/components use this as an starting point.

Here is some code for better understanding:

import {push} from "react-router-redux";

let myAction = (dispatch, value) => {
        dispatch(push(`/path/to/${value}`); # NOTE: This path must be absolute
};