I'm building a react app using material ui and nextjs. I'm using <Autocomplete />
component, provided by material UI and override some its styles with my own like this:
<Autocomplete
classes={{
root: `${styles[`search__autocomplete`]} ${
styles[`search--${variant}__autocomplete`]
}`,
inputRoot: `${styles[`search__autocomplete-input`]} ${
styles[`search--${variant}__autocomplete-input`]
}`
}}
/>
variant
is a prop, which gets passed to the component and styles
is a variable, which get imported from the css module: import styles from "Search.module.sass"
.
Now, when I'm working on this locally everything looks great:
But, after I deploy it to production via next build && next export
I start experiencing "flickering" effect when for like 1/3 of a second my page looks like this:
My guess is that it might be related to the fact that nextjs export my css to several files on production:
<link
rel="preload"
href="/_next/static/css/4dcd7fa805fb41261f08.css"
as="style"
/>
<link
rel="stylesheet"
href="/_next/static/css/4dcd7fa805fb41261f08.css"
data-n-g=""
/>
<link
rel="preload"
href="/_next/static/css/a23cf79bceae4047fddb.css"
as="style"
/>
<link
rel="stylesheet"
href="/_next/static/css/a23cf79bceae4047fddb.css"
data-n-p=""
/>
How can I solve that?