`<html.div>Count: {count}</html.div>` children not rendered on native due to being an array, not a `string`
Ninguém assumiu esta issue ainda.
Avaliação
- Dificuldade
- 3/5
- Tempo estimado
- 1-2 dias
- Facilidade para iniciantes
- 68/100
- Tipo de issue
- Bug
- Clareza
- Razoavelmente clara
- Status de atividade
- Ativa
- Stack de tecnologia
- javascript, react, react-native
Direção de pesquisa
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.
Escrita pelo modelo de indexação a partir do texto da issue.
Descrição
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;
}
- Linguagem predominante
- JavaScript
- Estrelas
- 3.6k
- Forks
- 208
- Métricas de merge de PRs
- Nenhum PR com merge em 30d
Preparar o ambiente
- Sem Dockerfile nem arquivo Docker Compose
- Sem modelo de pull request
- Ler o guia de contribuição
Primeiros passos
- Leia a issue inteira e depois o guia de contribuição do projeto.
- Comente na issue dizendo que vai assumir — evita que duas pessoas façam o mesmo trabalho.
- Faça um fork do repositório e trabalhe em uma branch.
- Abra um pull request que referencie o número da issue.
Mais de react/react-strict-dom
-
Outline styles aren't parsed in React NativeTalvez já em andamento @hoangvvo assumiu há 167 dias. Abertabug
Dificuldade 2/5 1-3 horas Facilidade para iniciantes 65/100
react/react-strict-dom#467 · 1 comentário ·
-
Missing disabled propAberta
Dificuldade 2/5 1-3 horas Facilidade para iniciantes 68/100
react/react-strict-dom#465 · 2 comentários ·
-
Dificuldade 3/5 1-2 dias Facilidade para iniciantes 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)Talvez já em andamento @borisyankov assumiu há 36 dias. Aberta
Dificuldade 5/5 Mais de uma semana Facilidade para iniciantes 35/100
react/react-strict-dom#520 ·
-
css.defineVars() with kebab-case keys warns unrecognized custom property and fails to resolveAbertabug
Dificuldade 2/5 1-3 horas Facilidade para iniciantes 35/100
react/react-strict-dom#505 · 2 reações ·
Todas as issues de react/react-strict-dom
Issues semelhantes
-
[Feature Request] [Web] Expose kvCacheQuantizationBits in the onnxruntime-web WebGPU EP optionsAbertaep:WebGPU platform:web quantization
Dificuldade 2/5 1-3 horas Facilidade para iniciantes 66/100
microsoft/onnxruntime#33752 ·
Mantenedores costumam responder em até 2 dias
-
More Transport Mode IconsAbertaicon request
Dificuldade 2/5 1-3 horas Facilidade para iniciantes 66/100
tabler/tabler-icons#1693 ·
Mantenedores costumam responder em até 1 dia
-
Dificuldade 1/5 1-3 horas Facilidade para iniciantes 72/100
alvarotrigo/fullPage.js#4755 ·
-
Dificuldade 2/5 1-3 horas Facilidade para iniciantes 64/100
jlab-sensing/ENTS-backend#854 ·
-
enhancement
Dificuldade 2/5 1-3 horas Facilidade para iniciantes 76/100
andromarces/agent-loops#1242 ·
Mantenedores costumam responder em até 1 dia