undefined不是和object(评估'_props [registrationName]')

wp2*_*123 7 ontouch react-native

反应天然:0.43.3

问题只出现在Android系统中,iOS很好.当我触摸TouchableOpacity组件时,将不会执行onTouch功能.

有人发现这个问题吗?

我用RN建了一个日历.问题是,当我点击Android设备或模拟器上的Day单元时,我将得到错误undefined不是和object(评估'_props [registrationName]').但是可以在iOS设备和模拟器上单击它.Day组件的代码如下:

        <TouchableOpacity style={styles.calendarRowUnit} onPress={() => this.props.onSelect(this.props.date)}>
            <View style={dateWrapperStyle}>
                <Text style={dateTextStyle}>{dateString}</Text>
            </View>
        </TouchableOpacity>
Run Code Online (Sandbox Code Playgroud)

和错误图像: 错误信息iamge

我发现只有当我触摸文本区域时才会出现错误. 我不知道这是一个反应原生的错误或我的错.在将react-native版本更新为0.43.3之前,错误从未发生过.

ato*_*ies 16

/**
   * @param {object} inst The instance, which is the source of events.
   * @param {string} registrationName Name of listener (e.g. `onClick`).
   * @return {?function} The stored callback.
   */
  getListener: function(inst, registrationName) {
    var listener;

    // TODO: shouldPreventMouseEvent is DOM-specific and definitely should not
    // live here; needs to be moved to a better place soon
    if (typeof inst.tag === 'number') {
      const props = EventPluginUtils.getFiberCurrentPropsFromNode(
        inst.stateNode
      );
      if (!props) {
        // Work in progress.
        return null;
      }
      listener = props[registrationName];
      if (shouldPreventMouseEvent(registrationName, inst.type, props)) {
        return null;
      }
    } else {
      if (typeof inst._currentElement === 'string') {
        // Text node, let it bubble through.
        return null;
      }
      if (!inst._rootNodeID) {
        // If the instance is already unmounted, we have no listeners.
        return null;
      }
      const props = inst._currentElement.props;
      listener = props[registrationName];
      if (shouldPreventMouseEvent(registrationName, inst._currentElement.type, props)) {
        return null;
      }
    }

    invariant(
      !listener || typeof listener === 'function',
      'Expected %s listener to be a function, instead got type %s',
      registrationName,
      typeof listener
    );
    return listener;
  },
Run Code Online (Sandbox Code Playgroud)

目前有一个错误,如果TextTouchableOpacity内部有一个number错误输出.暂时修复它的方法是将其转换number为a string,它将触发String检查并适当地抛出null.

EX:

之前:<Text>16</Text> 之后:<Text>String(16)</Text>