Open mdo5004 opened 2 years ago
I should note this behaves the same way in Next v11 and was not introduced in v12.
I suspect the issue has something to do with dynamic values in react-jss.
In MyDynamicComponent.js
, if you comment out the two lines that use dynamic values to generate CSS, everything behaves as expected.
const useStyles = createUseStyles({
root: {
border: '1px solid black',
// backgroundColor: ({ color }) => color,
// color: ({ color }) => color === 'blue' ? 'white' : 'black',
padding: 10,
textAlign: 'center',
},
other: {
border: '1px solid black',
backgroundColor: 'green',
padding: 10,
textAlign: 'center',
},
});
What version of Next.js are you using?
12.0.2-canary.1
What version of Node.js are you using?
12.22.5
What browser are you using?
Chrome
What operating system are you using?
macOS
How are you deploying your application?
next export
Describe the Bug
Styles generated with react-jss do not work as expected in development mode on first render.
Expected Behavior
I expect the first load of a page/component in development mode to match the first load of a page/component in production mode.
To Reproduce
Min repo can be found here: https://github.com/mdo5004/nextjs-dynamic-css-values-bug
I used the official example as the starting point.
To see the expected behavior,
npm run build && npm run export && serve out
Initially you should see a red box and a blue box. After toggling, you should see two blue boxes.
To see the unexpected behavior:
npm run dev
Initially you see a red box and an unstyled box. After toggling, you should see two blue boxes, but neither box has the expected background color.
After clicking the "About" link at the top and then navigating back, the styles load as expected.