React Native External Stylesheet

前端 未结 9 1023
你的背包
你的背包 2021-02-03 23:12

Is there a way in React Native that I can put all of my styles in a single file so it can easily be maintained (from my perspective) like in HTML we have a .css fil

9条回答
  •  萌比男神i
    2021-02-03 23:41

    You could add this module to your pipeline, and create a Gulp, or Webpack task to transpile the CSS into JavaScript.

    https://github.com/sabeurthabti/react-native-css

    In my experience you're best of not using the same CSS for web and react native, because React Native's stylesheets don't actually cascade.


    Or if you're willing to change your pipeline a little bit, PostCSS, which is a CSS4 to CSS3 transpiler, which supports all the features of SASS, can also be used to transpile, CSS to JavaScript

    https://github.com/postcss/postcss-js

提交回复
热议问题