In react-native we use styleSheet.create. What do we use in reactjs?

In react-native we use styleSheet.create. What do we use in reactjs?

Thanks for the help!

I dont see any use of style here but there is styling. how did he achieve this or did i miss out anything?


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.

You can use inline style property like:

<div style={{ background: 'red' }}>

Or simply plain css / scss.

There is also PostCSS you could look into.

Regarding you edit,

In the DevTools.js, you can see some inline style that gets passed as props to the <ChartMonitor />.

There is some className definitions like here that will aloow you to change the style in CSS.

You have three options:

  1. Inline Styles
  2. CSS Stylesheet
  3. CSS Modules

There is an excellent Styling React Components' course on Pluralsight that covers all of these options

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: {

Need Your Help

Offline Install of R on RedHat

r redhat epel

I am trying to install R on a RedHat server with no connectivity to the Internet. (sigh)

Huffman decoding in c using tree

c tree decoding prefix huffman-code

I've got to decompress a string that was encoded with a Huffman tree, but the code has variable length and not all inputs are in prefix, in which case I should print "invalid" and finish execution....