react-native-modal用于调试但不用于发布

时间:2019-01-21 15:57:49

标签: reactjs react-native debugging react-native-ios

我在react-native中使用react-native-modal,当我在调试时它非常完美,但是当应用程序发布时,该应用程序冻结了我尝试切换它的那一刻,我不知道为什么并没有在依赖项的仓库中找到这样的问题,我也没有在stackoverflow中找到任何东西

这是我的package.json

  "dependencies": {
    "axios": "^0.18.0",
    "i18n-js": "^3.1.0",
    "moment": "^2.22.2",
    "native-base": "^2.8.1",
    "react": "16.6.1",
    "react-native": "0.57.5",
    "react-native-actionsheet": "^2.4.2",
    "react-native-audio": "^4.2.2",
    "react-native-checkbox": "^2.0.0",
    "react-native-dropdownalert": "^3.7.0",
    "react-native-firebase": "^5.1.1",
    "react-native-gesture-handler": "^1.0.9",
    "react-native-image-crop-picker": "^0.21.3",
    "react-native-languages": "^3.0.2",
    "react-native-material-dropdown": "^0.11.1",
    "react-native-material-textfield": "^0.12.0",
    "react-native-modal": "^7.0.2",
    "react-native-modal-datetime-picker": "^6.0.0",
    "react-native-onesignal": "^3.2.8",
    "react-native-opentok": "^2.1.0",
    "react-native-sound": "^0.10.9",
    "react-native-spinkit": "^1.1.1",
    "react-native-splash-screen": "^3.1.1",
    "react-native-stars": "^1.1.5",
    "react-navigation": "^3.0.0"
  },
  "devDependencies": {
    "babel-jest": "23.6.0",
    "jest": "23.6.0",
    "metro-react-native-babel-preset": "0.49.2",
    "react-test-renderer": "16.6.1"
  },

这是我的modal.js

import React from 'react';

import Modals from 'react-native-modal';

const Modal = props => (
    <Modals isVisible={ props.is_visible } onBackdropPress={ () => props.toggle_modal(false) }>
        { props.children }
    </Modals>
)

export default Modal;

这是我如何使用它的一个例子

<TouchableOpacity onPress={ () => this.toggle_modal('is_change_language_modal_visible') } style={ styles.settings_item_container }>

    <Text style={ styles.settings_item_label }> { i18n.t('change_language') } </Text>

</TouchableOpacity>

<Modal is_visible={ this.state.is_change_language_modal_visible } toggle_modal={ () => this.toggle_modal('is_change_language_modal_visible') }>

   <ChangeLanguage
     change_language={ this.change_language }
   />

</Modal>

1 个答案:

答案 0 :(得分:0)

在Android设备上调试应用

您是否通过 logcat 在设备上获得了一些输出?

您可以在USB连接的设备上运行logcat,以获取更多有关应用退出的原因的反馈。 Android-Studio可以用作logcat的不错的gui,但是还有其他一些工具...至少使用adb logcat命令。

如何在Android Studio中启动Logcat

如果您使用的是android-studio,请确保将Projectfolder中的/ android-Directory用作Project-Root(不要使用react-native-project-root!)。然后按SHIFT键并输入Logcat来打开Logcat

在IOS设备上调试应用

对于IO,请使用:xcrun instruments -s devices

您甚至可以使用XCode这样打开它:

  1. 启动Xcode
  2. Windows->设备和模拟器
  3. 选择您的设备
  4. 点击按钮Open Console