错误: undefined不是一个对象(评估'_this.context.router.history')
index.js:
<Left>
<Link to="/menu">
<Image
source={require("./src/assets/images/home.png")}
style={styles.homeIcon}
/>
</Link>
</Left>
...
<NativeRouter>
<Container>
<Stack>
<Route exact path="/" component={Login} />
<Route
path="/menu"
component={() => <Menu showMenuIcon={this.showMenuIcon} />}
/>
<Route
path="/dialog"
component={() => <Dialog showMenuIcon={this.showMenuIcon} />}
/>
...
</Stack>
</Container>
</NativeRouter>
点击链接后显示错误。怎么了?
答案 0 :(得分:0)
尝试将nativeHistory添加到您的路线
import {nativeHistory} from 'react-router-native';
<Router history={nativeHistory}>
</Router>