Skip to content

MarkdownTextInput crashes with __workletHash error #666

Closed
@seanoliver

Description

@seanoliver

Hey team,

I'm trying to use MarkdownTextInput with the parseExpensiMark parser as recommended in the docs, but I'm encountering a runtime error:

Cannot read property '__workletHash' of undefined

I've followed the setup instructions, including patching html-entities to be worklet-safe.

Repro Code:

import React, { useState } from 'react';
import { MarkdownTextInput, parseExpensiMark } from '@expensify/react-native-live-markdown';

export default function Page() {
  const [text, setText] = useState('Hello, world!');

  return (
    <MarkdownTextInput
      parser={parseExpensiMark}
      value={text}
      onChangeText={setText}
    />
  );
}

Patched html-entities:

I patched the html-entities package by adding 'worklet'; directives to the decode and decodeEntity functions. My installed version didn't include a lib/index.js file as mentioned in the error message mentioned here, so I modified the dist/commonjs/index.js file instead. This approach seemed appropriate given the structure of the package in my pnpm setup, but I could be wrong.

Here's the diff:

diff --git a/dist/commonjs/index.js b/dist/commonjs/index.js
index f871ed4..bd7b9b5 100644
--- a/dist/commonjs/index.js
+++ b/dist/commonjs/index.js
@@ -108,6 +108,7 @@ function getDecodedEntity(entity, references, isAttribute, isStrict) {
 }
 /** Decodes a single entity */
 function decodeEntity(entity, _a) {
+    'worklet';
     var _b = _a === void 0 ? defaultDecodeEntityOptions : _a, _c = _b.level, level = _c === void 0 ? 'all' : _c;
     if (!entity) {
         return '';
@@ -116,6 +117,7 @@ function decodeEntity(entity, _a) {
 }
 /** Decodes all entities in the text */
 function decode(text, _a) {
+    'worklet';
     var _b = _a === void 0 ? defaultDecodeOptions : _a, _c = _b.level, level = _c === void 0 ? 'all' : _c, _d = _b.scope, scope = _d === void 0 ? level === 'xml' ? 'strict' : 'body' : _d;
     if (!text) {
         return '';

Babel Configuration (if useful):

// babel.config.js
module.exports = {
  presets: ['babel-preset-expo'],
  plugins: ['react-native-reanimated/plugin'],
};

Package Versions:

Here's a snippet from my package.json:

{
  "dependencies": {
    "@expensify/react-native-live-markdown": "^0.1.267",
    "expensify-common": "^2.0.129",
    "react-native-reanimated": "~3.17.4",
    "html-entities": "^2.6.0",
    "react-native": "0.77.0"
  }
}

Additional Context:

  • I'm using Expo SDK 52 and RN 0.77.0
  • I've cleared caches and rebuilt the project using expo start -c.

Despite these steps, the error persists. Is there something I'm missing, or is there an alternative approach to using parseExpensiMark with MarkdownTextInput?

Thanks once again for your help!

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions