I am reading the documentation on the React Rescript website on using CSS and almost nothing seems to work for me and stackoverflow and google are also not helping.
- Inline Styles
The documentation gives a simple example <div style={ReactDOM.Style.make(~color="#444444", ~fontSize="68px", ())} />
but what if the CSS property has hyphens? ex: list-style-type: none;? the code doesn’t compile and there is no guidance on how to use CSS properties with “-”
- Global CSS
I followed the documentation and wrote this code
%%raw("require('./main.css')")
@react.component
let make = () => {
<header>
<h1> { React.string("This is my tutorial") } </h1>
<nav>
<ul className="menu">
<li> { React.string("Menu") } </li>
<li> { React.string("About") } </li>
<li> { React.string("Contact") } </li>
</ul>
</nav>
</header>
}
doesn’t work throws error “SyntaxError: Unexpected token ‘.’”
- CSS Modules
changed my code to
@module external styles: {..} = "./main.css"
@react.component
let make = () => {
<header>
<h1> { React.string("This is my tutorial") } </h1>
<nav>
<ul className={styles["menu"]}>
<li> { React.string("Menu") } </li>
<li> { React.string("About") } </li>
<li> { React.string("Contact") } </li>
</ul>
</nav>
</header>
}
Doesn’t work same error.
Posted on stackoverflow and one line tip on using post-processors like webpack because browser doesn’t understand CSS but there is no guidance how to exactly set this up for a rescript project and I’m totally lost.
Can anyone help? I have checked in my whole code here just in case if you want to look at my full project.