简体   繁体   中英

How can I use style tag in JSX

So I'm in a situation where I have to use <style> tag, That is because I have multiple pages (I'm using react router DOM) so I cant apply the same style to every page as that would mess things up. Is there a way I can use <style> tag in JSX?

I have to use style tag like this:

function RandomScreen(){
    return (
        <div>
          <style></style>
        </div>
    )
}

You can simply import a stylesheet into your page:

import './main.css'

Another solution is to use Emotion and the Global component: https://emotion.sh/docs/globals

Can you use separate css file for every component and import every css file in every component you need.

import './RandomScreen.css';

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM