Hacktoberfest 2026: những issue maintainer đã đánh dấu cho tháng Mười, đang mở và phù hợp người mới. Xem issue Hacktoberfest

`<html.div>Count: {count}</html.div>` children not rendered on native due to being an array, not a `string`

Đang mở
#525 1 bình luận 1 reaction 0 người được giao Xem trên GitHub

Chưa có ai nhận issue này.

Đánh giá

Độ khó
3/5
Thời gian dự kiến
1-2 ngày
Mức phù hợp với người mới
68/100
Loại issue
Lỗi
Độ rõ ràng
Khá rõ ràng
Mức độ hoạt động
Sôi nổi
Công nghệ
javascript, react, react-native
Lĩnh vực
frontend, mobile

Hướng nghiên cứu

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.

Do mô hình lập chỉ mục viết ra từ nội dung của issue.

Mô tả

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
  1. Render the example above in a React Native application using React Strict DOM.
  2. Observe that the template-string example renders.
  3. 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-dom 0.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;
}
Ngôn ngữ chính
JavaScript
Star
3.6k
Fork
208
Chỉ số merge pull request
Không có pull request nào được merge trong 30 ngày

Chuẩn bị môi trường

Bắt đầu từ đâu

  1. Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
  2. Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
  3. Fork repository và làm thay đổi trên một nhánh.
  4. Mở pull request có tham chiếu số hiệu của issue.

Issue khác của react/react-strict-dom

Tất cả issue của react/react-strict-dom

Issue tương tự

Thêm issue về JavaScript

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.