【问题标题】:react-router-native doesnt workreact-router-native 不起作用
【发布时间】:2018-05-28 04:46:58
【问题描述】:

错误: 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>

点击链接后显示错误。怎么了?

【问题讨论】:

标签: reactjs react-native react-router-native


【解决方案1】:

尝试将 nativeHistory 添加到您的路线中

import {nativeHistory} from 'react-router-native';

<Router history={nativeHistory}>

</Router>

【讨论】:

猜你喜欢
  • 2020-10-08
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2019-04-17
  • 1970-01-01
  • 2018-07-31
相关资源
最近更新 更多