将 navigationOptions 导出为组件

Export navigationOptions as a component

是否可以以及如何将导航选项作为组件导出和导入

static navigationOptions = ({ navigation }) => {
return {
  headerLeft: (<Text />),
  title: (
    <Image style={{width: 500, height: 125}} source={require("../images/logo_orfo.png")} />
  ),
};

};

它不能是 React 组件,因为该函数不 return 任何 JSX 或 React.createElement 实例。但是,您可以像这样将其用作模块:

NavComponent.js

//imports here

export default ({ navigation }) => {
 return {
  headerLeft: (<Text />),
  title: (
    <Image style={{width: 500, height: 125}} source=
 {require("../images/logo_orfo.png")} />
  ),
 }; 
};

然后像这样导入

import NavComponent from './NavComponent';
...
static navigationOptions = NavComponent