Dev hydration omits React’s warning for an unexpected attribute on <html>

オープン
#190 コメント 0 件 リアクション 0 件 担当者 0 名 GitHub で見る

メンテナーはふだん 1 日以内に返信

まだ誰も着手していません。

評価

難易度
3/5
見積もり時間
1〜2日
初心者へのやさしさ
68/100
issue の種類
バグ
明瞭さ
明確に書かれている
活発さ
活発
技術スタック
react, typescript
領域
frontend, testing

調査の方向性

Start by tracing the development hydration path used by hydrateRoot and compare its handling of unexpected attributes with the React 19.3.1 behavior described here. Use the supplied jsdom reproduction with the extra argument, then check the matching-HTML control. Done means development hydration reports the unexpected element and attribute while preserving the DOM and leaving recoverable errors unused.

索引モデルが issue の本文から書いたものです。

説明

When the DOM has an extra attribute before hydrateRoot(document, …) runs, React 19.3.1 logs a development diagnostic identifying the element and attribute. Redact 0.3.1 hydrates the same document silently. We encountered this in a TanStack Start dev server with the Redact Vite plugin. The standalone reproduction below also triggers it without Vite or a browser extension.

Development runtime Matching HTML Extra data-extra="true" on <html>
React DOM 19.3.1 Quiet One console.error with an attribute diff
Redact 0.3.1 Quiet No console.error or console.warn

Both runtimes completed hydration and retained the extra attribute. Neither invoked onRecoverableError. This differs from the text mismatch in #62, where React recovers by re-rendering.

Reproduction

Install [email protected], [email protected], @tanstack/[email protected], and [email protected]. Save this as repro.mjs.

import { JSDOM } from 'jsdom'

const { window } = new JSDOM(
  '<!doctype html><html lang="en"><head></head><body><main>Home</main></body></html>'
)
for (const key of ['window', 'document', 'Node', 'Element', 'HTMLElement', 'Text',
  'Comment', 'Document', 'DocumentFragment', 'MutationObserver']) {
  globalThis[key] = window[key]
}

const redact = process.argv[2] === 'redact'
const { createElement: h } = await import(redact ? '@tanstack/redact' : 'react')
const { hydrateRoot } = await import(redact ? '@tanstack/redact/dom-client' : 'react-dom/client')
if (process.argv[3] === 'extra') document.documentElement.dataset.extra = 'true'

await new Promise(resolve => {
  const main = h('main', { ref: node => { if (node) resolve() } }, 'Home')
  hydrateRoot(document, h('html', { lang: 'en' }, h('head'), h('body', null, main)), {
    onRecoverableError: error => console.log('recoverable:', error.message),
  })
})
console.log('Hydrated. data-extra =', document.documentElement.getAttribute('data-extra'))
window.close()
NODE_ENV=development node repro.mjs react extra
NODE_ENV=development node repro.mjs redact extra

Omit extra for the matching-HTML control. React’s diff includes the line - data-extra="true".

Expected behavior

Please report unexpected DOM attributes during development hydration, with enough context to identify the element and attribute. The existing DOM can stay as it is. This would let developers diagnose SSR differences with the Redact plugin enabled.

主要言語
TypeScript
スター
640
フォーク
32
平均マージ
1時間 15分
マージ済み PR(30日)
7

環境構築

このプロジェクトには開発コンテナ、Dockerfile、コントリビューションガイドがありません。まず README を読み、一般的な手順ははじめてのコントリビューションガイドを参照してください。

はじめの一歩

  1. issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
  2. 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
  3. リポジトリをフォークし、ブランチを切って変更します。
  4. issue 番号を参照したプルリクエストを送ります。

TanStack/redact のほかの issue

TanStack/redact の issue をすべて見る

似ている issue

TypeScript の issue をもっと見る

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。