1

Error: undefined is not an object (evaluating '_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>

After click to Link displays an error. What's wrong?

kutirie
  • 583
  • 1
  • 4
  • 9

1 Answers1

0

Try adding nativeHistory to your routes

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

<Router history={nativeHistory}>

</Router>
Nico Van Belle
  • 4,911
  • 4
  • 32
  • 49
Roopak Puthenveettil
  • 1,387
  • 2
  • 13
  • 27
  • New error: http://prntscr.com/jnhipw, I doing the right thing? https://codepen.io/anon/pen/aKoNPZ?editors=0010 – kutirie May 28 '18 at 07:34