应用因发行版本而崩溃,错误未定义,不是一个对象(评估“ e.default”)

时间:2019-01-16 06:34:09

标签: javascript reactjs react-native jsx

我的应用在发布模式下崩溃,但在调试模式下运行良好。此问题是由于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检查。

以下是logcat报告:

[Info] 01-15 19:39:41.902 11958 11999 E ReactNativeJS: TypeError: undefined is not an object (evaluating 'e.default')
01-15 19:39:41.902 11958 11999 E ReactNativeJS: 
01-15 19:39:41.902 11958 11999 E ReactNativeJS: This error is located at:
01-15 19:39:41.902 11958 11999 E ReactNativeJS:     in t
01-15 19:39:41.902 11958 11999 E ReactNativeJS:     in inject-t-with-profileStore-store
01-15 19:39:41.902 11958 11999 E ReactNativeJS:     in t
01-15 19:39:41.902 11958 11999 E ReactNativeJS:     in RCTView
01-15 19:39:41.902 11958 11999 E ReactNativeJS:     in RCTView
01-15 19:39:41.902 11958 11999 E ReactNativeJS:     in RCTView
01-15 19:39:41.902 11958 11999 E ReactNativeJS:     in n
01-15 19:39:41.902 11958 11999 E ReactNativeJS:     in t
01-15 19:39:41.902 11958 11999 E ReactNativeJS:     in t
01-15 19:39:41.902 11958 11999 E ReactNativeJS:     in n
01-15 19:39:41.902 11958 11999 E ReactNativeJS:     in RCTView
01-15 19:39:41.902 11958 11999 E ReactNativeJS:     in t
01-15 19:39:41.902 11958 11999 E ReactNativeJS:     in RCTView
01-15 19:39:41.902 11958 11999 E ReactNativeJS:     in t
01-15 19:39:41.902 11958 11999 E ReactNativeJS:     in t
01-15 19:39:41.902 11958 11999 E ReactNativeJS:     in RCTView
01-15 19:39:41.902 11958 11999 E ReactNativeJS:     in n
01-15 19:39:41.902 11958 11999 E ReactNativeJS:     in t
01-15 19:39:41.902 11958 11999 E ReactNativeJS:     in n
01-15 19:39:41.902 11958 11999 E ReactNativeJS:     in u
01-15 19:39:41.902 11958 11999 E ReactNativeJS:     in e
01-15 19:39:41.902 11958 11999 E ReactNativeJS:     in t
01-15 19:39:41.902 11958 11999 E ReactNativeJS:     in RCTView
01-15 19:39:41.902 11958 11999 E ReactNativeJS:     in t
01-15 19:39:41.902 11958 11999 E ReactNativeJS:     in RCTView
01-15 19:39:41.902 11958 11999 E ReactNativeJS:     in RCTView
01-15 19:39:41.902 11958 11999 E ReactNativeJS:     in Unknown
01-15 19:39:41.902 11958 11999 E ReactNativeJS:     in RCTView
01-15 19:39:41.902 11958 11999 E ReactNativeJS:     in n
01-15 19:39:41.904 11958 11999 E ReactNativeJS: TypeError: TypeError: undefined is not an object (evaluating 'e.default')
01-15 19:39:41.904 11958 11999 E ReactNativeJS: 
01-15 19:39:41.904 11958 11999 E ReactNativeJS: This error is located at:
01-15 19:39:41.904 11958 11999 E ReactNativeJS:     in t
01-15 19:39:41.904 11958 11999 E ReactNativeJS:     in inject-t-with-profileStore-store
01-15 19:39:41.904 11958 11999 E ReactNativeJS:     in t
01-15 19:39:41.904 11958 11999 E ReactNativeJS:     in RCTView
01-15 19:39:41.904 11958 11999 E ReactNativeJS:     in RCTView
01-15 19:39:41.904 11958 11999 E ReactNativeJS:     in RCTView
01-15 19:39:41.904 11958 11999 E ReactNativeJS:     in n
01-15 19:39:41.904 11958 11999 E ReactNativeJS:     in t
01-15 19:39:41.904 11958 11999 E ReactNativeJS:     in t
01-15 19:39:41.904 11958 11999 E ReactNativeJS:     in n
01-15 19:39:41.904 11958 11999 E ReactNativeJS:     in RCTView
01-15 19:39:41.904 11958 11999 E ReactNativeJS:     in t
01-15 19:39:41.904 11958 11999 E ReactNativeJS:     in RCTView
01-15 19:39:41.904 11958 11999 E ReactNativeJS:     in t
01-15 19:39:41.904 11958 11999 E ReactNativeJS:     in t
01-15 19:39:41.904 11958 11999 E ReactNativeJS:     in RCTView
01-15 19:39:41.904 11958 11999 E ReactNativeJS:     in n
01-15 19:39:41.904 11958 11999 E ReactNativeJS:     in t
01-15 19:39:41.904 11958 11999 E ReactNativeJS:     in n
01-15 19:39:41.904 11958 11999 E ReactNativeJS:     in u
01-15 19:39:41.904 11958 11999 E ReactNativeJS:     in e
01-15 19:39:41.904 11958 11999 E ReactNativeJS:     in t
01-15 19:39:41.904 11958 11999 E ReactNativeJS:     in RCTView
01-15 19:39:41.904 11958 11999 E ReactNativeJS:     in t
01-15 19:39:41.904 11958 11999 E ReactNativeJS:     in RCTView
01-15 19:39:41.904 11958 11999 E ReactNativeJS:     in RCTView
01-15 19:39:41.904 11958 11999 E ReactNativeJS:     in Unknown
01-15 19:39:41.904 11958 11999 E ReactNativeJS:     in RCTView
01-15 19:39:41.904 11958 11999 E ReactNativeJS:     in n
01-15 19:39:41.904 11958 11999 E ReactNativeJS: 
01-15 19:39:41.904 11958 11999 E ReactNativeJS: This error is located at:
01-15 19:39:41.904 11958 11999 E ReactNativeJS:     in e
01-15 19:39:41.904 11958 11999 E ReactNativeJS:     in t
01-15 19:39:41.904 11958 11999 E ReactNativeJS:     in RCTView
01-15 19:39:41.904 11958 11999 E ReactNativeJS:     in t
01-15 19:39:41.904 11958 11999 E ReactNativeJS:     in RCTView
01-15 19:39:41.904 11958 11999 E ReactNativeJS:     in RCTView
01-15 19:39:41.904 11958 11999 E ReactNativeJS:     in Unknown
01-15 19:39:41.904 11958 11999 E ReactNativeJS:     in RCTView
01-15 19:39:41.904 11958 11999 E ReactNativeJS:     in n
01-15 19:39:41.904 11958 11999 E ReactNativeJS: TypeError: TypeError: undefined is not an object (evaluating 'e.default')
01-15 19:39:41.904 11958 11999 E ReactNativeJS: 
01-15 19:39:41.904 11958 11999 E ReactNativeJS: This error is located at:
01-15 19:39:41.904 11958 11999 E ReactNativeJS:     in t
01-15 19:39:41.904 11958 11999 E ReactNativeJS:     in inject-t-with-profileStore-store
01-15 19:39:41.904 11958 11999 E ReactNativeJS:     in t
01-15 19:39:41.904 11958 11999 E ReactNativeJS:     in RCTView
01-15 19:39:41.904 11958 11999 E ReactNativeJS:     in RCTView
01-15 19:39:41.904 11958 11999 E ReactNativeJS:     in RCTView
01-15 19:39:41.904 11958 11999 E ReactNativeJS:     in n
01-15 19:39:41.904 11958 11999 E ReactNativeJS:     in t
01-15 19:39:41.904 11958 11999 E ReactNativeJS:     in t
01-15 19:39:41.904 11958 11999 E ReactNativeJS:     in n
01-15 19:39:41.904 11958 11999 E ReactNativeJS:     in RCTView
01-15 19:39:41.904 11958 11999 E ReactNativeJS:     in t
01-15 19:39:41.904 11958 11999 E ReactNativeJS:     in RCTView
01-15 19:39:41.904 11958 11999 E ReactNativeJS:     in t
01-15 19:39:41.904 11958 11999 E ReactNativeJS:     in t
01-15 19:39:41.904 11958 11999 E ReactNativeJS:     in RCTView
01-15 19:39:41.904 11958 11999 E ReactNativeJS:     in n
01-15 19:39:41.904 11958 11999 E ReactNativeJS:     in t
01-15 19:39:41.904 11958 11999 E ReactNativeJS:     in n
01-15 19:39:41.904 11958 11999 E ReactNativeJS:     in u
01-15 19:39:41.904 11958 11999 E ReactNativeJS:     in e
01-15 19:39:41.904 11958 11999 E ReactNativeJS:     in t
01-15 19:39:41.904 11958 11999 E ReactNativeJS:     in RCTView
01-15 19:39:41.904 11958 11999 E ReactNativeJS:     in t
01-15 19:39:41.904 11958 11999 E ReactNativeJS:     in RCTView
01-15 19:39:41.904 11958 11999 E ReactNativeJS:     in RCTView
01-15 19:39:41.904 11958 11999 E ReactNativeJS:     in Unknown
01-15 19:39:41.904 11958 11999 E ReactNativeJS:     in RCTView
01-15 19:39:41.904 11958 11999 E ReactNativeJS:     in n
01-15 19:39:41.904 11958 11999 E ReactNativeJS: 
01-15 19:39:41.904 11958 11999 E ReactNativeJS: This error is located at:
01-15 19:39:41.904 11958 11999 E ReactNativeJS:     in e
01-15 19:39:41.904 11958 11999 E ReactNativeJS:     in t
01-15 19:39:41.904 11958 11999 E ReactNativeJS:     in RCTView
01-15 19:39:41.904 11958 11999 E ReactNativeJS:     in t
01-15 19:39:41.904 11958 11999 E ReactNativeJS:     in RCTView
01-15 19:39:41.904 11958 11999 E ReactNativeJS:     in RCTView
01-15 19:39:41.904 11958 11999 E ReactNativeJS:     in Unknown
01-15 19:39:41.904 11958 11999 E ReactNativeJS:     in RCTView
01-15 19:39:41.904 11958 11999 E ReactNativeJS:     in n
[Info] 01-15 19:39:41.943 11958 11958 D ReactNative: ReactInstanceManager.detachViewFromInstance()

0 个答案:

没有答案