`<html.div>Count: {count}</html.div>` children not rendered on native due to being an array, not a `string`
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
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
- 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;
}
- 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
- Không có Dockerfile hay tệp Docker Compose
- Không có mẫu pull request
- Đọc hướng dẫn đóng góp
Bắt đầu từ đâu
- Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
- 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.
- Fork repository và làm thay đổi trên một nhánh.
- Mở pull request có tham chiếu số hiệu của issue.
Issue khác của react/react-strict-dom
-
Outline styles aren't parsed in React NativeCó thể đã có người làm @hoangvvo đã nhận 168 ngày trước. Đang mởbug
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 65/100
react/react-strict-dom#467 · 1 bình luận ·
-
Missing disabled propĐang mở
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 68/100
react/react-strict-dom#465 · 2 bình luận ·
-
Độ khó 3/5 1-2 ngày Mức phù hợp với người mới 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)Có thể đã có người làm @borisyankov đã nhận 37 ngày trước. Đang mở
Độ khó 5/5 Hơn một tuần Mức phù hợp với người mới 35/100
react/react-strict-dom#520 ·
-
css.defineVars() with kebab-case keys warns unrecognized custom property and fails to resolveĐang mởbug
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 35/100
react/react-strict-dom#505 · 2 reaction ·
Tất cả issue của react/react-strict-dom
Issue tương tự
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 70/100
solana-foundation/solana-web3.js#4015 · 1 bình luận ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 82/100
gramps-project/gramps-web#1604 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
enhancement good first issue hacktoberfest help wanted
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 85/100
BinaryBaconLabs/todo-app#18 ·
-
Cache airport lookupsĐang mởenhancement
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 66/100
sutantyo/flight-watch#32 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
bug
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 88/100
Maintainer thường phản hồi trong vòng 1 ngày