React-native-router-flux: Warning: BackAndroid is deprecated. Please use BackHandler instead.

Created on 4 May 2017  ·  10Comments  ·  Source: aksonov/react-native-router-flux

Version

Tell us which versions you are using:

  • react-native-router-flux v3.38.0
  • react-native v0.44.0

Expected behaviour

There should no such warning message say Warning: BackAndroid is deprecated. Please use BackHandler instead.

Actual behaviour

there is warning message say Warning: BackAndroid is deprecated. Please use BackHandler instead. and caused by code in react-native-router-flux/src/Router.js

Steps to reproduce

  1. open app integrated with rnrf
  2. navigate to some view through Actions.xxxxxx
  3. or press hardware back button.
  4. the warning message would be shown at bottom of the screen.

Most helpful comment

I have fixed that manually,
Edit /node_modules/react-native-router-flux/src/Router.js
Find and replace each "BackAndroid" with "BackHandler" with the following lines:

  • Line 13
  • Line 55
  • Line 64

Final updated code should be like this:
import { BackHandler } from 'react-native';
...
...
componentDidMount() { BackHandler.addEventListener('hardwareBackPress', this.handleBackAndroid); }
...
...
componentWillUnmount() { BackHandler.removeEventListener('hardwareBackPress', this.handleBackAndroid); }

I hope this will help you 👍

All 10 comments

Same here:

Version

Tell us which versions you are using:

  1. react-native-router-flux v3.38.0 (v3.38.1 still has the Dimension error)
  2. react-native v0.44.0
  3. react 16.0.0-alpha.6

Have any good news for this issue?

@kesha-antonov has already created a PR for this: https://github.com/aksonov/react-native-router-flux/pull/1819

so am I,I guess the react-native 0.44 has conflict with react-native-router-flux,for i saw a demo used r-n-r-f with 0.38 version of the react-native run well.

0.42version, rectify

Same issue here. Also, getting an additional warning:

View.propTypes has been deprecated and will be removed in a future version of ReactNative. Use ViewPropTypes instead.

Version:

react-native-router-flux v3.38.0 (v3.38.1 still has the Dimension error)
react-native v0.44.0
react 16.0.0-alpha.6

Still got the problem on 3.39.1 with RN 0.43.4.
Hope it will be fixed soon !

Still got the problem.

react-native-router-flux: 3.39.1
react-native: 0.44
react: 16.0.0-alpha.6

Still getting the warning.

I have fixed that manually,
Edit /node_modules/react-native-router-flux/src/Router.js
Find and replace each "BackAndroid" with "BackHandler" with the following lines:

  • Line 13
  • Line 55
  • Line 64

Final updated code should be like this:
import { BackHandler } from 'react-native';
...
...
componentDidMount() { BackHandler.addEventListener('hardwareBackPress', this.handleBackAndroid); }
...
...
componentWillUnmount() { BackHandler.removeEventListener('hardwareBackPress', this.handleBackAndroid); }

I hope this will help you 👍

Was this page helpful?
0 / 5 - 0 ratings