Answers:
您可以创建一个可重用的样式表。例:
style.js
'use strict';
var React = require('react-native');
var {
  StyleSheet,
} = React;
module.exports = StyleSheet.create({
alwaysred: {
    backgroundColor: 'red',
    height: 100,
    width: 100,
},
});
在您的组件中:
var s = require('./style');
...然后:
<View style={s.alwaysred} ></View>
              import { StyleSheet } from 'react-native';
                    style={defaultStyle}添加。相反,您可以创建一个,DefaultView并使用它来代替view为您的规范样式化的。不久前,我写了一个答案,详细介绍了此方法:stackoverflow.com/a/52429040/5243543
                    为您的样式创建一个文件(IE,Style.js)。
这是一个例子:
import { StyleSheet } from 'react-native';
export default StyleSheet.create({
  container: {
    flex: 1
  },
  welcome: {
    fontSize: 20
  }
});
在要使用样式的任何文件中,添加以下内容:
import styles from './Style'
              如果您只想设置一些全局变量,则可以尝试。
AppStyles.js
export default AppStyles = {
    colour: {
        background: '#f4f9fd',
        font: '#434e5a',
        primary: '#ff3b30'
    }
}
index.ios.js
import AppStyles from './AppStyles';
const styles = StyleSheet.create({
    container: {
        backgroundColor: AppStyles.colour.background
    }
});
              您还可以尝试支持全局样式变量的react-native-extended-stylesheet:
// app.js
EStyleSheet.build({
   buttonColor: 'green'
});
// component.js
var styles = EStyleSheet.create({
  button: {
    backgroundColor: '$buttonColor',
    ...
  }
});
              您必须创建一个文件来存储所有样式(例如“ styles.js ”),并根据需要编写css类型代码
'use strict';
import {StyleSheet} from 'react-native';
export default StyleSheet.create({
    container: {
        flex: 1,
        justifyContent: 'center',
        alignItems: 'center',
        backgroundColor: '#F5FCFF',
    },
    title: {
        fontSize: 10,
        color: '#000',
        backgroundColor: '#fff'
    },
    button: {
        fontSize: 12,
        color: '#000',
        backgroundColor: '#fff'
    }
});
现在您可以使用全局样式
import React, { Component } from 'react';
import { View, Button } from 'react-native';
import StyleSheet from './config/styles';
export default class App extends Component {
  render() {
    return (
      <View
        style={StyleSheet.container}>
        <Button
          style={StyleSheet.button}
          title="Go to Lucy's profile"
        />
      </View>
    );
  }
}
              试试我的库react-native-style-tachyons,它不仅为您提供全局样式,而且还提供设计优先的响应式布局系统,其宽度和高度相对于您的根字体大小。
所有这些方法都直接回答了这个问题,但是就我而言,这不是在基于组件的设计系统(如React)中实现的方法。
我们可以从原子组件开始,然后将它们分层并一直分组到顶部。以下文章可能使这种思路更加清晰:http : //atomicdesign.bradfrost.com/chapter-2/
在自然界中,原子元素结合在一起形成分子。这些分子可以进一步结合形成相对复杂的生物。
如果您需要一个不存在的基本组件,则可以使用它。然后,您可以使用它来制作其他不太具体的组件。例如:
// rerender is cheaper without style prop when
// the default style is an unchanged reference
// instead of a new object every time.
const style = {
  color   : 'MidnightBlue',
  fontSize: 14,
}
function getStyle (styleProp) {
  // styleProp is able to overwrite style
  if (styleProp) return {...style, ...styleProp}
  else return style
}
export default function CustomText (props) {
  return (
    <Text style={getStyle(props.style)}>
      {props.children}
    </Text>
  )
}
然后CustomText在所有地方使用而不是Text。你也可以用它做View,div,span或其他任何东西。
<Text />在<CustomText />任何地方替换一样简单。您甚至可以将CustomText导入为Text,因此只需替换导入即可。
                    外部CSS文件main.css
'use strict';
var {
   StyleSheet,
 } = 'react-native';
module.exports = StyleSheet.create({
  main: {
     backgroundColor: 'gray',
     height: 20,
     width: 100,
  }
});
在组件中创建css文件的实例。
var mainCss = require('./main');
<View style={mainCss.main}><Text>Hello</Text></View>
              在这里,您可以找到一种优雅的方式来对样式进行排序,然后将其导入到不同的组件中,可以创建一个文件夹,在其中收集所有样式文件,并创建将用作外观的index.js:
index.js将如下所示:
import Variables from './variables';
import GlobalStyles from './global'; 
export { Variables, GlobalStyles };
然后像这样导入:
import { GlobalStyles } from './stylesheets/index';
在这里获取更多信息:
https://thoughtbot.com/blog/structure-for-styling-in-react-native
看看React Native的Shoutem主题。
这是您通过Shoutem Theme获得的功能:
全局样式,其中某些样式通过其样式名称自动应用于组件:
const theme = {
  'my.app.ComponentStyleName': {
    backgroundColor: 'navy',
  },
};
使用激活特定于组件的样式styleName(例如CSS类):
const theme = {
  'my.app.ComponentStyleName': {
    '.rounded': {
      borderRadius: 20,
    },
    backgroundColor: 'navy',
  },
};
// Implementation - will apply borderRadius to Component
<Component styleName="rounded"/>
自动样式继承:
const theme = {
  'my.app.ComponentStyleName': {
    'my.app.ChildComponentStyleName': {
      backgroundColor: 'red',
    },
    '.rounded': {
      borderRadius: 20,
    },
    backgroundColor: 'navy',
  },
};
// Implementation - will apply red background color to ChildComponent
<Component styleName="rounded">
  <ChildComponent/>
</Component>
组成组件的嵌套样式:
const theme = {
  'my.app.ComponentStyleName': {
    containerView: {
      paddingTop: 10,
    },
    innerView: {
      backgroundColor: 'yellow',
    },
  },
};
// Of course do not forget to connect Component
function Component({ style }) {
  return (
   <View style={style.containerView}>
    <View style={style.innerView}>
     <Text>Warning with yellow background.</Text>
    </View>
   </View>
  );
}
要使其正常工作,您需要使用StyleProvider,包装器组件通过上下文为所有其他组件提供样式。与Redux相似StoreProvider。
另外,您需要将组件与样式连接在一起,connectStyle以便始终使用连接的组件。与Redux相似connect。
export const styledComponent = connectStyle('my.app.ComponentStyleName',
                                { ...defaultStyleIfAny })(Component);
您可以在文档中查看示例。