How to disable the back button on certain React Navigation routes with React Native

1

Hello, I'm working with React Navigation and I'm having problems with the "back" button on certain screens.

My navigator is as follows:

import React from 'react'
import { FluidNavigator } from 'react-navigation-fluid-transitions'

import SplashScreen from '../../screens/SplashScreen'
import LoginScreen from '../../screens/LoginScreen'
import RegisterCodeScreen from '../../screens/RegisterScreen/RegisterCodeScreen'
import RegisterEmailScreen from '../../screens/RegisterScreen/RegisterEmailScreen'
import RegisterInfoScreen from '../../screens/RegisterScreen/RegisterInfoScreen'
import LanScreen from '../../screens/LanScreen'

export default Navigator = FluidNavigator({
  SplashScreen: { screen: SplashScreen },
  LoginScreen: { screen: LoginScreen, },
  RegisterEmailScreen: { screen: RegisterEmailScreen },
  RegisterCodeScreen: { screen: RegisterCodeScreen },
  RegisterInfoScreen: { screen: RegisterInfoScreen },
  LanScreen: { screen: LanScreen }
});

I need to lock the "back" only on the LoginScreen and LanScreen screens, and for that (currently) I'm using the resource below:

export defaut class LoginScreen extends React.Component {

  componentDidMount() {
    BackHandler.addEventListener('hardwareBackPress', () => true);
  }

  // ....

}

The problem is that using BackHandler causes it to disable on all routes and I do not want this ... How to solve?

    
asked by anonymous 14.10.2018 / 23:36

0 answers