⬆️Migration v3 -> v4
Upgrade MUI
If you are using MUI you must upgrade @mui/material to v5.10.7 or newer.
Breaking changes
SSR setup
MUI users can now setup SSR as per described in the MUI documentation. Nothing specific to tss-react is required.
// src/pages/_app.tsx
-import type { EmotionCache } from "@emotion/cache";
-import createCache from "@emotion/cache";
-import { CacheProvider } from '@emotion/react';
+import { createEmotionSsrAdvancedApproach } from "tss-react/nextJs";
-let muiCache: EmotionCache | undefined = undefined;
-export const createMuiCache = () => muiCache = createCache({ "key": "mui", "prepend": true });
+const { EmotionCacheProvider, withEmotionCache } = createEmotionSsrAdvancedApproach({ "key": "css" });
+export { withEmotionCache };
function App({ Component, pageProps }: AppProps) {
...
- <CacheProvider value={muiCache ?? createMuiCache()}>
+ <EmotionCacheProvider>
<MuiThemeProvider theme={theme}>
<CssBaseline />
<Component {...pageProps} />
</MuiThemeProvider>
- </CacheProvider>
+ </EmotionCacheProvider>
);
useCssAndCx removed
useCssAndCx removeduseMergedClasses removed
useMergedClasses removedRemoving noise
Explicitly providing an emotion cache is still supported but no longer required.
Having issues?
🆘Fix broken styles after upgrading to MUI v5 with TSSLast updated
Was this helpful?
