Skip to content
This repository was archived by the owner on Jul 9, 2026. It is now read-only.
This repository was archived by the owner on Jul 9, 2026. It is now read-only.

RCTFatalException: Unhandled JS Exception: TypeError: undefined is not an object (evaluating 't.replace') #4560

Closed
WordPress/gutenberg
#38670

Description

@sentry

Sentry Issue iOS: WORDPRESS-IOS-3KEM
Sentry Issue Android: https://sentry.io/share/issue/f3a114ae1a0c49acb11ae0a9e64e1f20/

RCTFatalException: Unhandled JS Exception: TypeError: undefined is not an object (evaluating 't.replace'): Unhandled JS Exception: TypeError: undefined is not an object (evaluating 't.replace'), stack:
__unstableFilterAttributeValue@2572:905
p@2023:824
R@2023:3638
b@2023:4410
f@2023:1493
<unknown>@2449:6055
value@2060:9513
value@(null):(null)
d@39:184
v@39:327
b@39:381
T@39:692
ze@39:13169
X@39:5354
<unknown>@39:13517
Re@39:93444
Ce@39:12979
Le@39:13356
receiveEvent@39:13766
value@62:3579
<unknown>@62:758
value@62:2582
value@62:730
value@(null):(null)

  File "React-Core/React/Base/RCTAssert.m", line 146, in RCTFatal
  File "React-CoreModules/RCTExceptionsManager.mm", line 78, in -[RCTExceptionsManager reportFatal:stack:exceptionId:suppressRedBox:]
  File "React-CoreModules/RCTExceptionsManager.mm", line 148, in -[RCTExceptionsManager reportException:]
  File "React-Core/React/Base/RCTModuleMethod.mm", line 584, in -[RCTModuleMethod invokeWithBridge:module:arguments:]
  File "React-Core/React/CxxModule/RCTNativeModule.mm", line 183, in facebook::react::invokeInner
...
(14 additional frame(s) were not displayed)

Desymbolized stacktrace:

gutenberg/packages/format-library/src/text-color/index.native.js:184:textColor.__unstableFilterAttributeValue
gutenberg/packages/rich-text/src/create.js:99:toFormat
gutenberg/packages/rich-text/src/create.js:436:createFromElement
gutenberg/packages/rich-text/src/create.js:371:createFromElement
gutenberg/packages/rich-text/src/create.js:197:create
gutenberg/packages/block-editor/src/components/rich-text/index.native.js:471:useCallback$argument_0
gutenberg/packages/rich-text/src/component/index.native.js:551:RichText#onPaste
value@(null):(null)
gutenberg/node_modules/react-native/Libraries/Renderer/implementations/ReactNativeRenderer-prod.js:22:invokeGuardedCallbackImpl
gutenberg/node_modules/react-native/Libraries/Renderer/implementations/ReactNativeRenderer-prod.js:40:invokeGuardedCallback
gutenberg/node_modules/react-native/Libraries/Renderer/implementations/ReactNativeRenderer-prod.js:53:invokeGuardedCallbackAndCatchFirstError
gutenberg/node_modules/react-native/Libraries/Renderer/implementations/ReactNativeRenderer-prod.js:73:executeDispatch
gutenberg/node_modules/react-native/Libraries/Renderer/implementations/ReactNativeRenderer-prod.js:1029:executeDispatchesAndReleaseTopLevel
gutenberg/node_modules/react-native/Libraries/Renderer/implementations/ReactNativeRenderer-prod.js:360:forEachAccumulated
gutenberg/node_modules/react-native/Libraries/Renderer/implementations/ReactNativeRenderer-prod.js:1064:batchedUpdates$argument_0
gutenberg/node_modules/react-native/Libraries/Renderer/implementations/ReactNativeRenderer-prod.js:7943:batchedUpdatesImpl
gutenberg/node_modules/react-native/Libraries/Renderer/implementations/ReactNativeRenderer-prod.js:1010:batchedUpdates
gutenberg/node_modules/react-native/Libraries/Renderer/implementations/ReactNativeRenderer-prod.js:1041:_receiveRootNodeIDEvent
gutenberg/node_modules/react-native/Libraries/Renderer/implementations/ReactNativeRenderer-prod.js:1082:ReactNativePrivateInterface.RCTEventEmitter.register$argument_0.receiveEvent
gutenberg/node_modules/react-native/Libraries/BatchedBridge/MessageQueue.js:419:__callFunction
gutenberg/node_modules/react-native/Libraries/BatchedBridge/MessageQueue.js:116:__guard$argument_0
gutenberg/node_modules/react-native/Libraries/BatchedBridge/MessageQueue.js:370:__guard
gutenberg/node_modules/react-native/Libraries/BatchedBridge/MessageQueue.js:115:callFunctionReturnFlushedQueue

Activity

  1. added
    [Type] Bug
    on Feb 9, 2022
  2. self-assigned this
    on Feb 9, 2022
  3. changed the title [-]RCTFatalException: Unhandled JS Exception: TypeError: undefined is not an object (evaluating 't.replace'): Unhandled JS Exception: TypeError: undefined is not an object (evaluating 't.replace'), stack:[/-] [+]RCTFatalException: Unhandled JS Exception: TypeError: undefined is not an object (evaluating 't.replace')[/+] on Feb 9, 2022
  4. fluiddot commented on Feb 9, 2022

    @fluiddot
    Contributor

    The crash can be reproduced by adding the following HTML to a post/page (extracted from WordPress/gutenberg#35516 (review)):

    <!-- wp:paragraph -->
    <p>xzfd <span class="has-inline-color has-green-color">f</span><span class="has-inline-color has-red-color">ghfgh</span></p>
    <!-- /wp:paragraph -->
    

    Looks like the value of the attribute style can be undefined in some cases (as the one outlined above). So in order to fix the issue, we'd need to check if it's defined before manipulating it (reference).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

[Type] Bug

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions