如何解决错误:此导航器同时具有导航和容器道具

时间:2019-03-13 17:12:25

标签: javascript reactjs react-native

我正在使用带有反应导航的expo。 在转到屏幕时,我遇到了该错误。

  

错误:错误:此导航器同时具有导航和容器道具,   因此尚不清楚它是否应该拥有自己的状态。移除道具:“错误,   动画,hideNavBar,init,routeName,name”(如果导航器应   从导航道具获取其状态。如果导航器应该   保持自己的状态,请勿通过导航道具。

这是我的app.js

import React from "react";
import { Platform, StatusBar, StyleSheet, Text, View } from "react-native";
import LoginScreen from "./screens/LoginScreen";
import { Font } from "expo";
import TicketsListScreen from "./screens/TicketListScreen/index.js";
import { Router, Scene, Actions, ActionConst } from "react-native-router-flux";
import { Ionicons } from "@expo/vector-icons";

export default class App extends React.Component {
  constructor() {
    super();
    this.state = {
      isReady: false
    };
  }
  async componentWillMount() {
    await Font.loadAsync({
      Roboto: require("native-base/Fonts/Roboto.ttf"),
      Roboto_medium: require("native-base/Fonts/Roboto_medium.ttf"),
      ...Ionicons.font
    });
    this.setState({ isReady: true });
  }
  render() {
    // if (!this.state.isReady) {
    //   return <Expo.AppLoading />;
    // }
    // return <TicketsListScreen />;
    return (
      <Router>
        <Scene key="root">
          <Scene
            key="loginScreen"
            component={LoginScreen}
            animation="fade"
            hideNavBar={true}
            initial={true}
          />
          <Scene
            key="ticketsListScreen"
            component={TicketsListScreen}
            animation="fade"
            hideNavBar={true}
          />
        </Scene>
      </Router>
    );
  }
}

这是我的屏幕/TicketListScreen/index.js

import React, { Component } from "react";
import TicketsListScreen from "./TicketsListScreen";
import SideBar from "../../components/Navigator/SideBar";
import { createDrawerNavigator, createAppContainer } from "react-navigation";
const TicketScreenRouter = createDrawerNavigator(
  {
    Home: { screen: TicketsListScreen }
  },
  {
    contentComponent: () => <SideBar />
  }
);
export default createAppContainer(TicketScreenRouter);

如果我在app.js中使用遵循代码。 ticketScreen可以正常工作,但是会出现错误。

// if (!this.state.isReady) {
        //   return <Expo.AppLoading />;
        // }
        // return <TicketsListScreen />;

感谢您的进步

0 个答案:

没有答案