Skip to content

TSS-React rendering unstyled server-side with getInitialProps #231

Description

@GarthGartherson

Hello,

I'm noticing some strange flash of unstyled content (FOUC) when the page hydrates when attempting to apply the TSS-React Library. We are attempting to migrate from mui4 -> mui5 in our Next15 pages app. We are currently wrapping our app in both Providers along with cache providers inside of _app.tsx. I have made the simplest recreation of the issue that I could from my codebase.

You should be able to go to the 3000 preview and open it in a second tab. You will see a FOUC and then classes will load client side. If you disable Javascript I have found that the classes are being generated and applied, however there aren't any styles contained inside the classes.

https://codesandbox.io/p/devbox/objective-smoke-3hlsxj?workspaceId=ws_Rc538nWGw5Zsfskk6ogRHP

I have attempted to replicate the Make MUI and TSS use different caches section from https://docs.tss-react.dev/ssr/next.js. However, my editor locally and this sandbox refuse to compile while TSSReactProvider is passed into this function:

const {
    augmentDocumentWithEmotionCache: augmentDocumentWithEmotionCache_tss,
    withAppEmotionCache: withAppEmotionCache_tss
} = createEmotionSsrAdvancedApproach({ "key": "tss" }, TssCacheProvider); 


Thank you for creating this library. It is a lifesaver in terms of migration to mui5 and has taught me a lot about hydration/etc. I am really hoping I can get it to work.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions