RN 0.59.5 with RN-vector-icons 6.4.2 throwing BackAndroid is deprecated and has been removed from this package. Use BackHandler instead

℡╲_俬逩灬. 提交于 2019-12-11 21:14:52

问题


I just installing newer react native with RNVI and i get this error when using RNVI,

BackAndroid is deprecated and has been removed from this package. Use BackHandler instead

but everything is fine when i remove import FontAwesome from 'react-native-vector-icons/FontAwesome'; and <FontAwesome name="icon_name"/>

I've tried to search BackAndroid using vscode and even on RNVI github repo, but I can't find any BackAndroid

How can i fix this issue?


回答1:


BackAndroid is Deprecated

Don't Worry we have Backhandler instead of BackAndroid

Use "react-native-vector-icons": "^6.2.0",

Use Case : 

import { BackHandler } from 'react-native'

componentDidMount() {
    BackHandler.addEventListener('hardwareBackPress', this.handleBackPress);
  }

  componentWillUnmount() {
    BackHandler.removeEventListener('hardwareBackPress', this.handleBackPress);
  }

  handleBackPress = () => {
    this.goBack(); // works best when the goBack is async
    return true;
  }


来源:https://stackoverflow.com/questions/55918055/rn-0-59-5-with-rn-vector-icons-6-4-2-throwing-backandroid-is-deprecated-and-has

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!