React Native External Stylesheet

前端 未结 9 1083
你的背包
你的背包 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条回答
  •  暗喜
    暗喜 (楼主)
    2021-02-03 23:48

    I agree to @Chris Geirman solution. you can just create stylesSheet as mention above by Chris and import to any view. In case if you want to merge external styleSheet to your individual view/component stylesheet then you can use ES6 new feature Object.assign like so:

    styles = require('./StyleSheet');

    const viewStyle = Object.assign(styles, StyleSheet.create({ ... }); );

提交回复
热议问题