react-native 填坑集合

版权声明:本文为博主原创文章,未经博主允许不得转载。 https://blog.csdn.net/sinat_31231955/article/details/87971726

react-native巨坑,相关插件也巨坑,版本更新慢,维护不及时。

我手头使用的是RN目前最新版本0.57.8,以下均为此版本环境下遇到的问题,在解决问题时配合开发调试方法,事半功倍。

我使用的技术栈是:react-native(0.57.8)+ react-navigation + react-redux + ant-design + axios

项目中使用的插件有

安装插件切记:react-native link *

下面是几个开发中阶段遇到的问题及解决方法。
原生问题可以从rn论坛找,插件问题从GitHub上的issue找

1.初始化

  1. 初始化运行失败,一般是环境问题,还有可能是RN版本问题
    在这里插入图片描述
  2. sdk.dir sdk路径配置
A problem occurred configuring project ':app'.
SDK location not found. Define location with sdk.dir in the local.properties file or with an ANDROID_HOME environment

在这里插入图片描述

2.开发过程

  1. 绝对定位元素被键盘顶起

    打开android工程,在AndroidManifest.xml中配置如下:
 android:windowSoftInputMode=“stateAlwaysHidden|adjustPan”
  1. StatusBar 主题污染
componentDidMount() {
    this._navListener = this.props.navigation.addListener('didFocus', () => {
      StatusBar.setBarStyle('dark-content');
    });
  }
  componentWillUnmount() {
    this._navListener.remove();
  }
  1. React Native Text截断
    显示数字加粗后最后一位无法显示问题,添加
fontFamily: 'System'
  1. 使用Button进行路由跳转时报错

    这个错误一般只在开启Debug JS Remotely时出现,可以通过使用TouchableOpacity包裹或替换解决

  2. to be continue

猜你喜欢

转载自blog.csdn.net/sinat_31231955/article/details/87971726
今日推荐