question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Trans component alternative usage - wrong child number

See original GitHub issue

Describe the bug When I use Trans component like this https://react.i18next.com/latest/trans-component#alternative-usage . I have to set wrong child number to make it work properly.

Occurs in react-i18next version 10.11.0

Case 1 <Trans i18nKey={modal:${textKey}}>Hello! <br/> some text. </Trans> Translation string: "surveyCreatedText": "Hello! <1/> some text." This case is ok. Case 2 components = [<br />] <Trans i18nKey={modal:${textKey}} components={components} /> Translation string: "surveyCreatedText": "Hello! <1/> some text." Gives “Hello! some text.” without
Case 3 components = [<br />] <Trans i18nKey={modal:${textKey}} components={components} /> Translation string: "surveyCreatedText": "Hello! <0/> some text." Gives desired result and warning “Each child in a list should have a unique “key” prop. …”

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Comments:5 (3 by maintainers)

github_iconTop GitHub Comments

1reaction
jamuhlcommented, Jul 4, 2019

should be fixed in react-i18next@10.11.4

0reactions
zeckdudecommented, Nov 30, 2021

I’m still seeing the problem in version 11.8.13 😦

Here’s my code:

<Trans
  i18nKey="subscribeHeadlineCostPerMonth"
  values={{
    monthlyPrice: 20,
  }}
  components={[<wbr />]}
/>

That gives me the Each child in a list should have a unique "key" prop warning.

When I add the key to the component in the array, the warning goes away, but it sounds like this was already fixed previously?

<Trans
  i18nKey="subscribeHeadlineCostPerMonth"
  values={{
    monthlyPrice: 20,
  }}
  components={[<wbr key="somekey" />]}
/>
Read more comments on GitHub >

github_iconTop Results From Across the Web

Error in <Trans /> component with react-i18next - Stack Overflow
Any ideas? I have tried an alternative version where I use a template as the return value from the Trans component: <Trans t ......
Read more >
Trans Component - react-i18next documentation
Using with React components · Alternative usage which lists the components (v11.6.0) · Usage with simple HTML elements like <br /> and others...
Read more >
Alternatives to 'AFAB' and 'AMAB' | by Trans Style Guide
The obvious first answer would be those who view a fluid spectrum between “male” and “female” to be an adequate spectrum. Spectrum wheels...
Read more >
react-i18next | Yarn - Package Manager
Starting with v7.0.0 Trans component per default won't add a parent div around content passed as children. It will just return it's children....
Read more >
Inclusive Language Guidelines
The words we use are key to creating psychologically safe, inclusive, ... to join and be a part of a work group, organization,...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found