Comments (3)
@garronej I've totally misread the example and didn't create a new emotion cache for each server render.. I've now corrected it and it seems to work as expected!
Beside, do you use cx or something else to merge classe names?
I'm still using clsx()
to merge multiple classes, didn't understand what the advantage was.
I've read the source code of cx and it seems it overrides any media queries here? So that it more works like inline styles? Or does it do some additional things?
from tss-react.
Hi,
<TssCacheProvider value={getTssDefaultEmotionCache()}>
This is a no-op.
let cache: EmotionCache | undefined
/** Creates a single instance of the@emotion/cache
that is shared between server and client */
export function emotionCache() {
if (!cache) cache = createCache({ key: 'mui', prepend: true })
return cache
}
This is not a correct setup for SSR. A new instance of emotion cache must be created for every render on the server.
Please refer to the documentation.
Beside, do you use cx
or something else to merge classe names?
Please create a sandbox if you want me to provide further assistance. With stackblitz you can even create SSR playgrounds.
from tss-react.
does it do some additional things?
Yes it absolutely do additional things! It ensures styles are overwritten in the correct order!
const useStyles = makeStyles()({
"blue": {
"backgroundColor": "blue"
},
"red": {
"backgroundColor": "red"
}
});
function MyComponent(){
const { classes, cx } = useStyles();
return (
<div className={cx(classes.red, classes.blue)}>Hello World</div>
);
}
In this example the <div>
will have a blue background. But if I use cx(classes.blue, classes.red)
the <div>
will have a red background.
For what it does relative to media queries see this issue.
Best
from tss-react.
Related Issues (20)
- How to opt out of RTL transformation? HOT 3
- <GlobalStyles /> don't work properly with next.js app folder HOT 7
- cannot Import multiple makeStyles HOT 1
- Use eslint rule to detect unused classed with imports HOT 2
- React 16.10.0 failed to install @ mui/material HOT 1
- How to use with css and styled apis. HOT 1
- yarn install with pnp mode complains about missing dependency @mui/material HOT 3
- NextJS/MUI/TSS - Cannot read properties of undefined (reading 'classes') HOT 3
- Hard reload after any file change HOT 2
- TssCacheProvider is not working when used with emotion cache and mui 5 HOT 6
- Using with Shadowed Web Components HOT 3
- Next.js: Applying augmentDocumentWithEmotionCache to document breaks AMP pages HOT 2
- The right way typing props when using withStyles HOT 3
- Invalid type for withStyles HOT 4
- Mantine integration
- Using `@import` rule within `<GlobalStyles />` component HOT 8
- `GlobalStyles` create multiple <style data-emotion="css-global">...<style> HOT 1
- Cannot read properties of undefined (reading 'length') in useGuaranteedMemo HOT 3
- MUI V5: Performance issues HOT 4
- Prop `className` did not match. HOT 7
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from tss-react.