the onpress event is different from the docs

Please provide the following:

  1. SDK Version:42
  2. Platforms(Android/iOS/web/all):all
  3. Add the appropriate “Tag” based on what Expo library you have a question on.

when I try to console log the onpress event I get a long list of things but I don’t get what is mentioned in react-native website

what I get

Class {
  "_dispatchInstances": FiberNode {
    "tag": 5,
    "key": null,
    "type": "RCTView",
  },
  "_dispatchListeners": [Function onResponderRelease],
  "_targetInst": FiberNode {
    "tag": 5,
    "key": null,
    "type": "RCTView",
  },
  "bubbles": undefined,
  "cancelable": undefined,
  "currentTarget": ReactNativeFiberHostComponent {
    "_children": Array [
      ReactNativeFiberHostComponent {
        "_children": Array [
          23,
        ],
        "_internalFiberInstanceHandleDEV": FiberNode {
          "tag": 5,
          "key": null,
          "type": "RCTText",
        },
        "_nativeTag": 25,
        "viewConfig": Object {
          "directEventTypes": Object {
            "topInlineViewLayout": Object {
              "registrationName": "onInlineViewLayout",
            },
            "topTextLayout": Object {
              "registrationName": "onTextLayout",
            },
          },
          "uiViewClassName": "RCTText",
          "validAttributes": Object {
            "accessibilityActions": true,
            "accessibilityHint": true,
            "accessibilityLabel": true,
            "accessibilityLiveRegion": true,
            "accessibilityRole": true,
            "accessibilityState": true,
            "accessibilityValue": true,
            "accessible": true,
            "adjustsFontSizeToFit": true,
            "allowFontScaling": true,
            "collapsable": true,
            "dataDetectorType": true,
            "disabled": true,
            "ellipsizeMode": true,
            "importantForAccessibility": true,
            "isHighlighted": true,
            "maxFontSizeMultiplier": true,
            "minimumFontScale": true,
            "nativeID": true,
            "needsOffscreenAlphaCompositing": true,
            "numberOfLines": true,
            "onAccessibilityAction": true,
            "onAccessibilityEscape": true,
            "onAccessibilityTap": true,
            "onInlineViewLayout": true,
            "onLayout": true,
            "onMagicTap": true,
            "onTextLayout": true,
            "pointerEvents": true,
            "renderToHardwareTextureAndroid": true,
            "selectable": true,
            "selectionColor": true,
            "shouldRasterizeIOS": true,
            "style": Object {
              "alignContent": true,
              "alignItems": true,
              "alignSelf": true,
              "aspectRatio": true,
              "backfaceVisibility": true,
              "backgroundColor": Object {
                "process": [Function processColor],
              },
              "borderBottomColor": Object {
                "process": [Function processColor],
              },
              "borderBottomEndRadius": true,
              "borderBottomLeftRadius": true,
              "borderBottomRightRadius": true,
              "borderBottomStartRadius": true,
              "borderBottomWidth": true,
              "borderColor": Object {
                "process": [Function processColor],
              },
              "borderEndColor": Object {
                "process": [Function processColor],
              },
              "borderEndWidth": true,
              "borderLeftColor": Object {
                "process": [Function processColor],
              },
              "borderLeftWidth": true,
              "borderRadius": true,
              "borderRightColor": Object {
                "process": [Function processColor],
              },
              "borderRightWidth": true,
              "borderStartColor": Object {
                "process": [Function processColor],
              },
              "borderStartWidth": true,
              "borderStyle": true,
              "borderTopColor": Object {
                "process": [Function processColor],
              },
              "borderTopEndRadius": true,
              "borderTopLeftRadius": true,
              "borderTopRightRadius": true,
              "borderTopStartRadius": true,
              "borderTopWidth": true,
              "borderWidth": true,
              "bottom": true,
              "color": Object {
                "process": [Function processColor],
              },
              "decomposedMatrix": true,
              "direction": true,
              "display": true,
              "elevation": true,
              "end": true,
              "flex": true,
              "flexBasis": true,
              "flexDirection": true,
              "flexGrow": true,
              "flexShrink": true,
              "flexWrap": true,
              "fontFamily": Object {
                "process": [Function processFontFamily],
              },
              "fontSize": true,
              "fontStyle": true,
              "fontVariant": true,
              "fontWeight": true,
              "height": true,
              "includeFontPadding": true,
              "justifyContent": true,
              "left": true,
              "letterSpacing": true,
              "lineHeight": true,
              "margin": true,
              "marginBottom": true,
              "marginEnd": true,
              "marginHorizontal": true,
              "marginLeft": true,
              "marginRight": true,
              "marginStart": true,
              "marginTop": true,
              "marginVertical": true,
              "maxHeight": true,
              "maxWidth": true,
              "minHeight": true,
              "minWidth": true,
              "opacity": true,
              "overflow": true,
              "overlayColor": Object {
                "process": [Function processColor],
              },
              "padding": true,
              "paddingBottom": true,
              "paddingEnd": true,
              "paddingHorizontal": true,
              "paddingLeft": true,
              "paddingRight": true,
              "paddingStart": true,
              "paddingTop": true,
              "paddingVertical": true,
              "position": true,
              "resizeMode": true,
              "right": true,
              "rotation": true,
              "scaleX": true,
              "scaleY": true,
              "shadowColor": Object {
                "process": [Function processColor],
              },
              "shadowOffset": Object {
                "diff": [Function sizesDiffer],
              },
              "shadowOpacity": true,
              "shadowRadius": true,
              "start": true,
              "textAlign": true,
              "textAlignVertical": true,
              "textDecorationColor": Object {
                "process": [Function processColor],
              },
              "textDecorationLine": true,
              "textDecorationStyle": true,
              "textShadowColor": Object {
                "process": [Function processColor],
              },
              "textShadowOffset": true,
              "textShadowRadius": true,
              "textTransform": true,
              "tintColor": Object {
                "process": [Function processColor],
              },
              "top": true,
              "transform": Object {
                "process": [Function processTransform],
              },
              "transformMatrix": true,
              "translateX": true,
              "translateY": true,
              "width": true,
              "writingDirection": true,
              "zIndex": true,
            },
            "testID": true,
            "textBreakStrategy": true,
          },
        },
      },
    ],
    "_internalFiberInstanceHandleDEV": FiberNode {
      "tag": 5,
      "key": null,
      "type": "RCTView",
    },
    "_nativeTag": 27,
    "viewConfig": Object {
      "Commands": Object {},
      "bubblingEventTypes": Object {
        "topBlur": Object {
          "phasedRegistrationNames": Object {
            "bubbled": "onBlur",
            "captured": "onBlurCapture",
          },
        },
        "topChange": Object {
          "phasedRegistrationNames": Object {
            "bubbled": "onChange",
            "captured": "onChangeCapture",
          },
        },
        "topEndEditing": Object {
          "phasedRegistrationNames": Object {
            "bubbled": "onEndEditing",
            "captured": "onEndEditingCapture",
          },
        },
        "topFocus": Object {
          "phasedRegistrationNames": Object {
            "bubbled": "onFocus",
            "captured": "onFocusCapture",
          },
        },
        "topKeyPress": Object {
          "phasedRegistrationNames": Object {
            "bubbled": "onKeyPress",
            "captured": "onKeyPressCapture",
          },
        },
        "topPress": Object {
          "phasedRegistrationNames": Object {
            "bubbled": "onPress",
            "captured": "onPressCapture",
          },
        },
        "topSelect": Object {
          "phasedRegistrationNames": Object {
            "bubbled": "onSelect",
            "captured": "onSelectCapture",
          },
        },
        "topSubmitEditing": Object {
          "phasedRegistrationNames": Object {
            "bubbled": "onSubmitEditing",
            "captured": "onSubmitEditingCapture",
          },
        },
        "topTouchCancel": Object {
          "phasedRegistrationNames": Object {
            "bubbled": "onTouchCancel",
            "captured": "onTouchCancelCapture",
          },
        },
        "topTouchEnd": Object {
          "phasedRegistrationNames": Object {
            "bubbled": "onTouchEnd",
            "captured": "onTouchEndCapture",
          },
        },
        "topTouchMove": Object {
          "phasedRegistrationNames": Object {
            "bubbled": "onTouchMove",
            "captured": "onTouchMoveCapture",
          },
        },
        "topTouchStart": Object {
          "phasedRegistrationNames": Object {
            "bubbled": "onTouchStart",
            "captured": "onTouchStartCapture",
          },
        },
      },
      "directEventTypes":...(truncated to the first 10000 characters)

what in react-native website

{
    changedTouches: [PressEvent],
    identifier: 1,
    locationX: 8,
    locationY: 4.5,
    pageX: 24,
    pageY: 49.5,
    target: 1127,
    timestamp: 85131876.58868201,
    touches: []
}

I think you’re meant to look at event.nativeEvent.

e.g. the following shows ({ nativeEvent: PressEvent }) which implies to me that you should expect the event object to have a nativeEvent key which is of type PressEvent.

e.g. try this:

      <Button
        title="Click me"
        onPress={({ nativeEvent }) => {
          const e = { ...nativeEvent, changedTouches: '[...]' };
          Alert.alert('Event', JSON.stringify(e, null, 2));
        }}
      />

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.