I am trying to set up a new self convention to make my React code better organized like the following:
export default function HeaderExample() {
const compStyle = getStyle();
return (
<>
<h1>Hello World</h1>
<style jsx>{compStyle}</style>
</>
)
}
function getStyle() {
return `
h1 {
color: blue;
}
`
}
It works fine, but writing the return in getStyle() is pretty hard because I don't get formatting or syntax highlight help from the IDE.
How can I get those? Plugin / Library / Setting / Giving it a type? Any of those will help.
And at the same chance, do you think this can cause any issues down the road?




return css` ....-- it gets colored for me (and offers CSS code completion) i.imgur.com/9eKQCMS.png For that I had to clone bundled Language Injection rule forhtmland adjust it to be CSS (so no need for manual injections) i.imgur.com/tKVXM7O.png . Please note: I'm not JavaScript person at all and do not know if just prefixing a template string withcssis enough -- maybe some actual code is also needed (that handles thatcssprefix in some way).