facebook/react · error · Error

162

162

Error message

This should have a text node initialized. This error is likely caused by a bug in React. Please file an issue.

What it means

commitMutationEffectsOnFiber() applies a text update by calling the host's text-update path on the fiber's stateNode. A HostText fiber gets its instance in completeWork via createTextInstance; the Update flag with a null stateNode means the instance was never created or was lost - either an internal abort/reuse bug or, for custom renderers, a host config that returns null from createTextInstance.

Source

Thrown at packages/react-reconciler/src/ReactFiberCommitWork.js:2353

            // memory, point `alternate.stateNode` to new shadow node. This
            // prevents shadow node from staying in memory longer than it
            // needs to. The correct behaviour of this is checked by test in
            // React Native: ShadowNodeReferenceCounter-itest.js#L150
            finishedWork.alternate.stateNode = finishedWork.stateNode;
          }
        }
      }
      break;
    }
    case HostText: {
      recursivelyTraverseMutationEffects(root, finishedWork, lanes);
      commitReconciliationEffects(finishedWork, lanes);

      if (flags & Update) {
        // $FlowFixMe[constant-condition]
        if (supportsMutation) {
          if (finishedWork.stateNode === null) {
            throw new Error(
              'This should have a text node initialized. This error is likely ' +
                'caused by a bug in React. Please file an issue.',
            );
          }

          const newText: string = finishedWork.memoizedProps;
          // For hydration we reuse the update path but we treat the oldProps
          // as the newProps. The updatePayload will contain the real change in
          // this case.
          const oldText: string =
            current !== null ? current.memoizedProps : newText;

          commitHostTextUpdate(finishedWork, newText, oldText);
        }
      }
      break;
    }
    case HostRoot: {

View on GitHub (pinned to eafeac097b)

Solutions

  1. Renderer maintainers: make createTextInstance return a stable non-null opaque instance (a {text} object is fine)
  2. If using a third-party renderer, update it - non-null instances are part of the renderer contract
  3. On react-dom: update React and check whether the text sits inside a Suspense/Activity boundary suspending during the update
  4. File an issue naming the renderer and a minimal tree

Example fix

// before - custom renderer host config
createTextInstance: (text) => null,

// after - return an opaque non-null instance
createTextInstance: (text) => ({text}),
commitTextUpdate: (inst, newText) => { inst.text = newText; },
Defensive patterns

Strategy: validation

Validate before calling

// Custom-renderer smoke test: text creation must yield an instance
const inst = hostConfig.createTextInstance('probe', container, null, {});
if (inst == null) {
  throw new Error('hostConfig.createTextInstance must return a non-null instance');
}

Try / catch

If you cannot fix the host config, catch via onUncaughtError and re-render the subtree without text children as a degraded fallback.

Prevention

When it happens

Trigger: A custom renderer (react-reconciler host config) whose createTextInstance returns null or undefined; hydration where the text node was never adopted; React bugs where an interrupted render reused a HostText fiber without an instance and flagged it for update.

Common situations: Building or using custom renderers (canvas, PDF, 3D) that have no real text nodes and stub createTextInstance; text inside trees that suspend mid-commit; crashes reported after aborting concurrent renders.

Related errors


AI-assisted analysis of facebook/react@eafeac097b (2026-08-21). Data as JSON: /api/errors/da957d023d61123f. Report an issue: GitHub.