Can this be used in a single spa application?
See original GitHub issueI’m having issues using tss-react
in a single spa environment. In my root app, I am able to get the UMD version of MUI
and emotion
(not been able to find an umd/systemjs version of this package or create one successfully):
"@mui/material": "https://unpkg.com/@mui/material@5.4.3/umd/material-ui.production.min.js",
"@emotion/react": "https://cdn.jsdelivr.net/npm/@emotion/react@11.8.2/dist/emotion-react.umd.min.js",
"@emotion/styled": "https://cdn.jsdelivr.net/npm/@emotion/styled@11.8.1/dist/emotion-styled.umd.min.js",
And they are being externalised by webpack in the sub app I am trying to use tss-react
, In this app I have created a cache as the docs showed:
export const muiCache = createCache({
'key': 'mui',
'prepend': true,
});
// region Component
const Theme: FunctionComponent<IThemeProps> = ({
children,
style
}) => {
// handlers
const theme = React.useMemo(() => {
switch (style) {
case Themes.Default:
default:
return DefaultTheme;
}
}, [style]);
// render
return (
<CacheProvider value={muiCache}>
<MuiThemeProvider theme={theme}>
{children}
</MuiThemeProvider>
</CacheProvider>
);
};
But MUI
css always takes precedence over tss-react
created styles and cannot seem to get it to work. Is there a way to get this to work?
Issue Analytics
- State:
- Created 2 years ago
- Reactions:1
- Comments:13 (7 by maintainers)
Top Results From Across the Web
Frequently Asked Questions
No. We strongly encourage that your single-spa-config or root application does not use any JavaScript UI frameworks (React, Angular, Angularjs, Vue, etc) ...
Read more >Building Micro Frontends Using Single-SPA Framework
Single-page applications are packaged up into modules and combine with the container app. These applications can be built on top of different ...
Read more >What is single-spa framework? - Adservio
Single-spa frameworks differ from traditional web apps because they're a client-side application that works with the speed and performance of a ...
Read more >Deploy single application individually · Issue #123
Let's say I have a single-spa with 10 applications. ... I found out that I can use the predefined scripts to build the...
Read more >Connect Micro frontends with the Single-Spa framework. Step ...
This app will be responsible for connecting all the frameworks that we will use in the current article. Create a folder for the...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
@liztownd @garronej Documentation may need to change if you have made it
Your solution causes
single spa inspector
dev tool to not work, infinite loading. This seems like it will happen if you use single spa layout engine.To fix this, don’t create a new array with custom props added (
applicationsWithProps
in your example). Add the props to the route constructor like so:And then in your layout html file add the props to the application like this:
@garronej & @kennyist – I WIN! Lol.
In the root-config file when registering the sub applications I passed an instance of the createCache & CacheProvider from @emotion, then picked them up from the props rather than importing them in each sub-app (I had several apps all importing their own theme object and assigning classNames). Voila, I now have one muiCache, and the styles are appearing in order, pre-prending the
tss
styles, each with their own prefix depending on the sub-app they originated from.in root-config:
inside cache provider in every sub app: