Giter Site home page Giter Site logo

Comments (3)

paales avatar paales commented on July 20, 2024 1

@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.

garronej avatar garronej commented on July 20, 2024

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.

garronej avatar garronej commented on July 20, 2024

@paales

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)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.