TX002

Konsol kökü dışında render etme

Konsol

Text.js error TX002: Hooks and components must be rendered inside a console root (createConsoleRoot / renderToConsole).

Nedeni

Bir Text.js hook’u veya bileşeni (useInput, <ScrollBox>, …), konsol kökü olmayan bir React kökü altında render edildi; bu durum çoğunlukla react-dom konsol için tasarlanmış bir bileşeni render ettiğinde oluşur.

Çözümü

Konsol bileşenlerini react-dom yerine renderToConsole (veya createConsoleRoot) ile render edin:

import { renderToConsole, Box, Text } from "@textjs/react";await renderToConsole(  <Box padding={1}>    <Text>Hello, DevTools.</Text>  </Box>,);

Aynı arayüzü sayfada göstermek için @textjs/react/dom paketindeki, kendi konsol kökünü oluşturan <TextCanvas> bileşenini kullanın.