Skip to content

Commit

Permalink
feat(bridge-react): support basename passed by remote module props (#…
Browse files Browse the repository at this point in the history
  • Loading branch information
danpeen authored Dec 26, 2024
1 parent 835b09c commit 4102786
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 1 deletion.
5 changes: 5 additions & 0 deletions .changeset/twelve-pumpkins-film.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@module-federation/bridge-react': patch
---

feat: support basename passed by remote module props
4 changes: 3 additions & 1 deletion apps/router-demo/router-host-2000/src/App.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,9 @@ const App = () => {
<Route path="/detail/*" Component={Detail} />
<Route
path="/remote1/*"
Component={() => <Remote1App name={'Ming'} age={12} ref={ref} />}
Component={() => (
<Remote1App name={'Ming'} age={122} basename="/remote1" />
)}
/>
<Route
path="/remote2/*"
Expand Down
5 changes: 5 additions & 0 deletions packages/bridge/bridge-react/src/remote/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -158,6 +158,11 @@ export function withRouterData<
WrappedComponent: React.ComponentType<P & ExtraDataProps>,
): React.FC<Omit<P, keyof ExtraDataProps>> {
const Component = forwardRef(function (props: any, ref) {
if (props?.basename) {
return (
<WrappedComponent {...props} basename={props.basename} ref={ref} />
);
}
let enableDispathPopstate = false;
let routerContextVal: any;
try {
Expand Down

0 comments on commit 4102786

Please sign in to comment.