`<html.div>Count: {count}</html.div>` children not rendered on native due to being an array, not a `string`
Dieses Issue hat noch niemand übernommen.
Bewertung
- Schwierigkeit
- 3/5
- Geschätzter Aufwand
- 1-2 Tage
- Anfängerfreundlichkeit
- 68/100
- Issue-Typ
- Bug
- Klarheit
- Größtenteils klar
- Aktivitätsstatus
- Aktiv
- Tech-Stack
- javascript, react, react-native
Rechercherichtung
Start by locating the native implementation that wraps string children in TextString, then check its existing tests for view-backed elements such as html.div. Reproduce the difference between a template string and multiple primitive children on React Native. Done means both forms render “Count: 3” on native, with regression coverage for mixed string and numeric children.
Vom Indexierungsmodell aus dem Issue-Text verfasst.
Beschreibung
Describe the issue
On native, view-backed RSD elements such as html.div render a single string child correctly, but text disappears when JSX interpolation produces multiple primitive children.
For example, the first element below renders Count: 3, while the second is empty:
const count = 3;
<html.div>{`Count: ${count}`}</html.div>
<html.div>Count: {count}</html.div>
The interpolated form produces children equivalent to ['Count: ', 3].
Expected behavior
Both elements should render Count: 3, matching normal React DOM behaviour.
Steps to reproduce
- Render the example above in a React Native application using React Strict DOM.
- Observe that the template-string example renders.
- Observe that the interpolated string/number example is empty.
Test case
import { html } from 'react-strict-dom';
export function Example() {
const count = 3;
return (
<>
<html.div>{`Count: ${count}`}</html.div>
<html.div>Count: {count}</html.div>
</>
);
}
Additional comments
Reproduced with:
react-strict-dom0.0.55- React Native 0.85.3
The native implementation appears to wrap children in TextString only when typeof children === 'string'. Interpolation produces an iterable containing a string and number, which is passed directly to the native View and is not rendered.
Suggested fix
Replace typeof children === 'string' with the following checks:
function getTextContent(children: React.Node): ?string {
const nodes = React.Children.toArray(children);
const isTextOnly =
nodes.length > 0 &&
nodes.every(
(node) =>
typeof node === 'string' ||
typeof node === 'number' ||
typeof node === 'bigint'
);
return isTextOnly
? nodes.map((node) => String(node)).join('')
: null;
}
- Vorherrschende Sprache
- JavaScript
- Sterne
- 3.6k
- Forks
- 208
- PR-Merge-Kennzahlen
- Keine gemergten PRs in 30 T.
Entwicklungsumgebung
- Kein Dockerfile und keine Docker-Compose-Datei
- Keine Pull-Request-Vorlage
- Beitragsleitfaden lesen
Erste Schritte
- Lesen Sie das ganze Issue und danach den Beitragsleitfaden des Projekts.
- Schreiben Sie ins Issue, dass Sie es übernehmen — das erspart doppelte Arbeit.
- Forken Sie das Repository und arbeiten Sie in einem Branch.
- Öffnen Sie einen Pull Request, der die Issue-Nummer nennt.
Mehr aus react/react-strict-dom
-
Outline styles aren't parsed in React NativeEvtl. vergeben @hoangvvo hat das vor 176 Tagen übernommen. Offenbug
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 65/100
react/react-strict-dom#467 · 1 Kommentar ·
-
Missing disabled propOffen
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 68/100
react/react-strict-dom#465 · 2 Kommentare ·
-
Schwierigkeit 3/5 1-2 Tage Anfängerfreundlichkeit 69/100
react/react-strict-dom#524 ·
-
postcss plugin re-transforms every included file on each rebuild under Turbopack (minutes-long HMR in large projects)Evtl. vergeben @borisyankov hat das vor 45 Tagen übernommen. Offen
Schwierigkeit 5/5 Über eine Woche Anfängerfreundlichkeit 35/100
react/react-strict-dom#520 ·
-
bug
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 35/100
react/react-strict-dom#505 · 2 Reaktionen ·
Alle Issues in react/react-strict-dom
Ähnliche Issues
-
xsd:integer cast from a string rejects negative numbers, a leading + and surrounding whitespaceOffenbug 🐛
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 78/100
comunica/comunica#1960 · 1 Kommentar ·
Maintainer antworten meist innerhalb von 1 Tag
-
Waiting for: Product Owner
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 76/100
getsentry/sentry-javascript#26203 · 1 Kommentar ·
Maintainer antworten meist innerhalb von 1 Tag
-
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 70/100
Maintainer antworten meist innerhalb von 1 Tag
-
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 75/100
Maintainer antworten meist innerhalb von 1 Tag
-
bug
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 76/100
bytedance/flowgram.ai#1235 ·
Maintainer antworten meist innerhalb von 1 Tag