Replies: 4 comments 7 replies
-
@zllkjc Request to take a look at this. Its almost more than 2 week but no update on thread. Is it the problem of the way question is framed. Eagerly waiting for this to resolve. Tried lot of ways but no solution, no example in doc about how to persist any component across route change. Please correct if wrong anywhere |
Beta Was this translation helpful? Give feedback.
-
@zllkjc I think I manage to resolve issue after adding App.tsx to Header MFE (Link)
Does it mean when having multiple MFE they must implement self controlled routing. When you say react router generates frontend routes using conventional approach
is this required to know that which MFE to load from that particular child MFE? Sorry I'm deviating from the original question but just trying to understand the things as a whole |
Beta Was this translation helpful? Give feedback.
-
I feel there was a misunderstanding between us. I noticed your code uses Garfish, but I'm unsure if you intended to use Module Federation or Garfish. Garfish is an early micro-frontend solution in Modern.js that works at the application level, meaning each sub-application (like Header, Footer, Table) exists as a separate application. When using Garfish, if your sub-application has frontend routing (whether using "conventional routing" or "self-controlled routing"), the sub-application will detect route changes when the main application changes routes. If you want to use Garfish but don't want sub-applications to experience frontend route changes, you shouldn't add frontend routing in the sub-applications. You can write it directly like this: // Header's App.tsx
export default () => {
return (
<div>Header App inside route {Math.random()}</div>} />
);
}; The Table application is the same. However, in this scenario, there's actually no need to use Garfish, because your Header, Footer, and Table don't need to provide any application capabilities. I think you can use Module Federation to export these modules, or perhaps that's what you intended to use all along, but took the wrong approach. Generally, there's no need to use Garfish. The common scenario is when the main application serves as a skeleton, providing elements like sidebars and top bars, while the core parts are applications developed by other teams. You would typically use Garfish only when you need to collaborate separately. Module Federation also provides application-level module capabilities. For more details, you can refer to: |
Beta Was this translation helpful? Give feedback.
-
I intended to use micro frontend and then module federation as an incremental approach.
Ok then based on this and other comments I would try for module federation. But meanwhile I'm curious to know is it possible to navigate from sub-application (lets say Header / Footer) to masterApp/home page or loading another sub-application (lets say Table) in core part w/o full page reload and using any one approach (Garfish / Module Federation)? Thanks for explaining the things. |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
-
Hey,
I have created 4 apps masterApp, Header, Footer, Table and wanted to render Header and Footer always irrespective of route and Table component should get loaded on navigating to /table route.
pastebin code for masterApp/routes/layout.tsx - https://pastebin.com/4BbhYrSe
pastebin code for masterApp/routes/page.tsx - https://pastebin.com/sKkY4fv7
While initial load everything works perfectly fine.
If Heder and Footer are rendered as MFE before and after
<Outlet />
and clicked on Load table route then Table app is getting rendered but Header and Footer displays 404, not sure why?If rendered text before and after
<Outlet />
with Math.random() number (just to see if it rerenders or not on click of /table route) then in that case that text persist as is w/o changing randomly generated number. It means it is not rerendering.Not able to get where am I going wrong for having 2 types of behaviour. In case of rendering Header and Footer as MFE, they also should not rerender or display 404 and should persist.
Pastebin for masterApp modern.runtime.ts config - https://pastebin.com/WPG3RWB7
I am not sure if configuring the router is really required or not otherwise navigating to /table would not have loaded Table MFE which is working currently, maybe because of below setup (files inside routes folder based on conventional routing)

Tried lot of other options suggested by Github copilot but none of them is working and stuck here since few days and would appreciate any help.
Let me know if need any more details to debug the issue.
Thanks.
Beta Was this translation helpful? Give feedback.
All reactions