In react-native we use styleSheet.create. What do we use in reactjs?
The analogous option would be to do something like the following:
let styles = {
container: {
backgroundColor: 'red'
}
}
Like one of the comments stated above, the StyleSheet call is unecessary because CSS is supported already on the browser.
Finally, just call the style inline in your render function's return statement:
render() {
...
return (
<div style={styles.container} />
)
}
Of course, aside from that, you have a few other options as well, like using plain CSS stylesheets and classes/tags, but this is probably the most similar option to what you're used to.
If you are using TypeScript in your project you could define StyleSheet like this:
interface StyleSheet {
[key: string]: React.CSSProperties;
}
And then create styles very similar as with StyleSheet.create from RN.
const styles: StyleSheet = {
navStyle: {
listStyleType: 'none',
margin: 0,
padding: 0,
display: 'flex',
flexDirection: 'row',
width: '100%'
},
anotherStyle: {
...
}
}