3

i'm using react-router-native with an ejected CRNA app. i've added the <AndroidBackButton> component to my <NativeRouter> as it shows in the docs, but it doesn't seem to be firing.

is there some way i can debug this to see if it's just not getting a value properly? i'm using <Redirect> and <Link> in my app to do the routing, so there should history items for RR to work from.

any thoughts or ideas are welcome.

export default props => (
  <NativeRouter>
    <AndroidBackButton>
      <Switch>
        <Route exact path="/" component={Flash} />
        <Route path="/will_not_work" render={routeProps => <WillNotWork {...props} {...routeProps} />} />

        <View style={styles.container}>
          <Switch>
            <Route path="/menu" render={routeProps => <Menu {...props} {...routeProps} />} />
            <Route path="/car_compatibility" render={routeProps => <CarCompatibilityChecker {...props} {...routeProps} />} />
            <Route path="/how_it_works" render={routeProps => <HowItWorks {...props} {...routeProps} />} />
            <Route path="/app_demo" render={routeProps => <AppDemo {...props} {...routeProps} />} />
          </Switch>
        </View>
      </Switch>
    </AndroidBackButton>
  </NativeRouter>
);
rkstar
  • 1,178
  • 14
  • 27

1 Answers1

1

GOT IT.

after some extensive docs reading and scouring the internet for anyone with an even remotely similar problem, i found this.

when i looked at my MainActivity.java file, i saw that i had an empty onBackPressed function. i removed it, and voilĂ ! my back button works as expected.

here is the removed code from MainActivity.java:

@Override 
public void onBackPressed() { 

} 
rkstar
  • 1,178
  • 14
  • 27