single-spa / single-spa-playground

A website that helps you set up single-spa
http://single-spa-playground.org
MIT License
39 stars 10 forks source link

react app created by create-single-spa not working #17

Closed joeldenning closed 4 years ago

joeldenning commented 4 years ago

Screen Shot 2020-03-09 at 3 00 28 AM

Reported by Steve Back

Sauloxd commented 4 years ago

I managed to reproduce this bug on single-spa apps with / somewhere in the appName (ex: @react-mf/people). I think the culprit is how the ":appName" is handled in react router: Dynamic route for test app definition

 <Route path="/app/:appName" component={TestApp} />

How links to this route is being generated

<Link
  to={`/app/${applications[0].name}`}
  className="primary button"
>
  Next step: test it out
</Link>

Interpolating the to prop will result in /app/@react-mf/people where :appName will be mapped to @react-mf instead of @react-mf/people which is actually defined in the import-map! My proposed solution is to URI encode this appName and decode when TestApp page needs to get the appName from URL

joeldenning commented 4 years ago

👍 thanks for the fix.