1

错误: 未定义不是对象(评估“_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>

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

4

1 回答 1

0

尝试将 nativeHistory 添加到您的路线

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

<Router history={nativeHistory}>

</Router>
于 2018-05-28T06:49:10.207 回答