正如您在我的简单代码中看到的那样,我没有使用createNavigationContainer / createAppContainer,但是却遇到了该错误。我不知道为什么会这样。我被卡住了!
import React, { Component } from 'react';
import {Router, Stack, Scene} from 'react-native-router-flux';
import LogIn from './pages/LogIn';
import SignUp from './pages/SignUp';
import { View } from 'react-native';
export default class Routes extends React.Component {
render(){
return(
<Router>
<Stack key="root" hideNavBar={true}>
<Scene key="LogIn" component={LogIn} title="Login" initial={true}/>
<Scene key="SignUp" component={SignUp} title="SignUp"/>
</Stack>
</Router>
);
}
}
>
"dependencies": {
"expo": "^35.0.0",
"react": "16.8.3",
"react-dom": "16.8.3",
"react-native": "https://github.com/expo/react-native/archive/sdk-35.0.0.tar.gz",
"react-native-gesture-handler": "~1.3.0",
"react-native-reanimated": "~1.2.0",
"react-native-router-flux": "^4.0.6",
"react-native-screens": "~1.0.0-alpha.23",
"react-native-web": "^0.11.7",
"react-navigation": "^4.0.10",
"react-redux": "^7.1.3",
"react-scripts": "^3.2.0",
"redux": "^4.0.4",
"redux-thunk": "^2.3.0",
答案 0 :(得分:1)
试试看它是否对您有用
interface BaseParent<P extends BaseParent<P, C>, C extends BaseChild<P, C>> {
List<C> getChildren();
void setChildren(List<C> children);
P self();
default void addChild(C child) {
if (child.getParent() == null) {
child.setParent(self());
}
final ArrayList<C> newChildren = new ArrayList<>(getChildren());
newChildren.add(child);
setChildren(newChildren);
}
}
interface BaseChild<P extends BaseParent<P, C>, C extends BaseChild<P, C>> {
void setParent(P parent);
P getParent();
}
final class Parent implements BaseParent<Parent, Child> {
private List<Child> children = new ArrayList<>();
@Override
public List<Child> getChildren() {
return children;
}
@Override
public void setChildren(List<Child> children) {
this.children = children;
}
@Override
public Parent self() {
return this;
}
}
final class Child implements BaseChild<Parent, Child> {
private Parent parent;
public Child(Parent parent) {
this.parent = parent;
this.parent.addChild(this);
}
@Override
public void setParent(Parent parent) {
this.parent = parent;
}
@Override
public Parent getParent() {
return parent;
}
}
如果这不起作用,请尝试升级您的软件包
参考link
答案 1 :(得分:0)
请仔细阅读此重要说明,并像这样更改package.json上的版本
"react-navigation": "^4.0.10",
"react-native-router-flux": "4.2.0-beta.1",
重要提示
v4.2.0-beta.x基于React Navigation v4.x
v4.1.0-beta.x基于React Navigation v3.x
v4.0.x基于[React Navigation v2.x]。
请参阅此分支和基于v3的文档,该版本基于不推荐使用的React Native实验导航API。不支持它,并且可能不适用于最新的React Native版本。 v4.0.0-beta.x基于React Navigationv1.5.x。有关此版本,请参见此分支。它还不受支持,并且可能不适用于最新的React Native版本。