REECT本机路由器通量 - 预期组件类,当单击按钮转到另一个屏幕时获得[对象]



我在使用react-native-router-flux时获得了component类,这是我的app.js文件和组件文件。

app.js

import * as React from 'react';
import { Text, View, StyleSheet } from 'react-native';
import ScarletScreen from './components/ScarletScreen';
import GrayScreen from './components/GrayScreen';
import {Router, Scene} from 'react-native-router-flux';
const App = () => {
    return (
     <Router>
      <Scene key = "root">
        <Scene
          key = "scarlet"
          component =  {ScarletScreen }
          title = "Scarlet"
          initial
        />

      <Scene
          key = "gray"
          component = { GrayScreen }
          title = "Gray"
        />
      </Scene>
     </Router>
    );
  }
export default App;

Scarletscreen.js

import React, { Component } from 'react';
import { Text, View, Button } from 'react-native';
import { Actions } from 'react-native-router-flux';
const ScarletScreen = () => {
  return (
    <View
      style={{
        backgroundColor: '#bb0000',
        flex: 1,
        alignItems: 'center',
        justifyContent: 'center',
      }}>
      <Text>Scarlet Screen</Text>
      <Button title="IR PARA GRAY" onPress={() => Actions.gray()} />
    </View>
  );
};
export default ScarletScreen;

grayscreen.js

import React, { Component } from 'react';
import {Text, View} from 'react-native';
import { Actions } from 'react-native-router-flux';
const GrayScreen = () => {
  return(
    <View style={{backgroundColor: '#666666', flex: 1, alignItems: 'center', justifyContent: 'center'}}>
      <Text>Gray Screen</Text>
    </View>
  );
};

当我单击按钮时,显示错误"元素类型无效:预期字符串"。

您需要确保所有组件被导出。GrayScreen缺少导出。

export default Grayscreen

相关内容

  • 没有找到相关文章

最新更新