在发布模式下,React-native应用程序崩溃?

时间:2019-01-15 13:11:02

标签: javascript reactjs react-native

我的应用在发布模式下崩溃,但在调试模式下运行良好。此问题是由于Platform检查引起的。

实际上,没有该Platform检查代码,该应用即可正常运行。

这些是我正在执行动画的Keyboard个事件。

_keyboardDidShow = e => {
  keyboardHeight = e.endCoordinates.height,
  height = Platform.OS == "ios" ? keyboardHeight : 0
Animated.timing(this.state.bottomPadding, {
  toValue: 0,
  duration: 150
}).start();
Animated.timing(this.state.keyboardHeight, {
  toValue: height,
  duration: 150,
}).start();
this.setState({ isFocused: true });
}

_keyboardDidHide = () => {
this.setState({ isFocused: false });
Animated.timing(this.state.bottomPadding, {
  toValue: 0,
  duration: 150
}).start();
Animated.timing(this.state.keyboardHeight, {
  toValue: 0,
  duration: 0
}).start();
}

这是我正在制作动画的代码的一部分。

customFocusNavigator = () => {
return (
  <Animated.View
    style={[styles.FocusNavigator,{ bottom: this.state.keyboardHeight }]}
  >
    <View style={styles.FocusNavigatorDirectionBox}>
      <TouchableOpacity
        onPress={() => {
          this.state.index > 0
            ? this["customtext" + (this.state.index - 1)].changeFocus()
            : this["customtext0"].changeFocus();
        }}
        style={[
          styles.bottomSubView,
          { borderRightColor: constant.COLOR.WHITE, borderRightWidth: 1 }
        ]}
      >
        <Text style={styles.FocusNavigatorText}>Previous</Text>
      </TouchableOpacity>
      <TouchableOpacity
        onPress={() => {
          this.state.index < 4
            ? this["customtext" + (this.state.index + 1)].changeFocus()
            : this["customtext0"].changeFocus();
        }}
        style={styles.bottomSubView}
      >
        <Text style={styles.FocusNavigatorText}>Next</Text>
      </TouchableOpacity>
    </View>
    <TouchableOpacity
      onPress={() => {
        Keyboard.dismiss();
      }}
    >
      <Text style={[styles.FocusNavigatorText, { fontWeight: "bold" }]}>
        Done
      </Text>
    </TouchableOpacity>
  </Animated.View>
  );
 };

休息就是状态

 keyboardHeight: new Animated.Value(0),

如果我在KeyboardDidShow中给定硬编码值,假设300代替了高度,则应用程序不会崩溃,但是在添加Platform之后,请检查释放模式下的崩溃。我想要特定于平台的高度,因此需要Platform检查。

0 个答案:

没有答案