Skip to content

Markdown 组件在安卓的 H5 环境报错 Object.hasOnw is not a function #923

@huang-1234

Description

@huang-1234

Initial checklist

Affected package

"react-markdown": "10.1.0"

Steps to reproduce

Markdown 组件在安卓的 H5 环境报错 Object.hasOnw is not a function

Actual behavior

Based on the uploaded screenshot of the JavaScript error in an Android H5 environment, here is a precise English translation of the issue description:


Translated Issue Description (for Bug Reporting or Analysis)

Environment Context:
The error occurred in an Android H5 web application, as captured in a mobile screenshot. The device displayed the following status at the time (top status bar):

  • Timestamp: 17:02
  • Network Speed: 85.0 KB/s
  • Battery Level: 73%

Error Type:

  • TypeError (categorized as "Error 1 of 2" in the screenshot)

Core Error Message:

  • Object.hasOwnProperty is not a function
    (This indicates an undefined method call on the Object prototype)

Call Stack Details (from the error panel):

  • Initiated at: post in node_modules/react-markdown/lib/index.js:340:16
  • Followed by: Markdown in node_modules/react-markdown/lib/index.js:195:10
  • Entered React internals: renderWithHooks in node_modules/react-dom/cjs/react-dom.development.js:15486:18
  • Subsequent React lifecycle methods:
    • mountIndeterminateComponent (react-dom.development.js:20098:13)
    • beginWork (react-dom.development.js:21621:16)
    • Event handling: HTMLUnknownElement.callCallback and invokeGuardedCallbackDev (react-dom.development.js:4164:14 and 4213:16)
  • Ended with: performUnitOfWork (react-dom.development.js:26591:12)

Visual Context:

  • UI layout: Deep gray background with white/red text and yellow/white stack trace lines.
  • Bottom controls: "Prev," "Close," and "Next" buttons visible.

Summary in Technical Terms:
A TypeError in an Android WebView environment due to the absence of Object.hasOwnProperty implementation in older JavaScript engines. The crash originated in react-markdown during component rendering, specifically at the renderWithHooks phase of React. This is consistent with low-compatibility Android WebViews (e.g., Chrome < v93).


This description preserves all critical technical details from the screenshot, including file paths, line numbers, and environmental context, for accurate debugging or reporting. If you need an optimized fix or further analysis based on this translation, let me know!

Expected behavior

normal

Runtime

node@18.20.8

Package manager

npm@10.8.2

Operating system

Android@13

Build and bundle tools

swc

Metadata

Metadata

Assignees

No one assigned

    Labels

    🤞 phase/openPost is being triaged manually

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions