In react-native we use styleSheet.create. What do we use in reactjs?
Thanks for the help!
https://github.com/romseguy/redux-store-visualizer
I dont see any use of style here but there is styling. how did he achieve this or did i miss out anything?
A StyleSheet is an abstraction similar to CSS StyleSheets. Instead of creating a new style object every time, StyleSheet helps to create style objects with an ID which is further used to reference instead rendering it again.
create() Creates a StyleSheet style reference from the given object.
Inline styles are the most direct away to style any React application. Styling elements inline doesn't require you to create a separate stylesheet. Style applied directly to the elements as compared to styles in a stylesheet also have higher precedence.
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 love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With