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.

[object Object] on a standard Trans in selects

See original GitHub issue

Describe the bug I get [object Object] on some standard <Trans id="ui.foo">Foo</Trans> renders.

This happens only in some cases, and it seems to occur on Selects. The id is in the po file and compiled to js.

I’ve tried downgrading to 2.7.4 which didn’t help.

To Reproduce

https://codesandbox.io/s/boring-glitter-i847j

Expected behavior Display js file or default.

Workaround Replacing the Trans in question with an i18n._(t('ui.xyz')XYZ) resolves the issue. I will update the code sandbox with this.

Additional context

  • jsLingui version 2.7.4 | 2.8.3
  • Babel version 7.5.5
  • Your Babel config (e.g. .babelrc)

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Reactions:3
  • Comments:6 (1 by maintainers)

github_iconTop GitHub Comments

1reaction
tricoder42commented, Apr 30, 2020

Hey @mschipperheyn, unfortunately this isn’t related to Lingui as React itself doesn’t allow <option> to have React elements. See https://github.com/lingui/js-lingui/issues/655#issuecomment-621637390

This would cause the same problem:

        <select>
          <option>Text</option>
          <option>
            <p>Element</p>
          </option>
        </select>

We have to use i18n._ or t macro here

1reaction
wpq0commented, Nov 13, 2019

FWIW, here’s my work around https://codesandbox.io/s/silly-keller-475lp:

<Select name="test">
      <Trans id="ui.select" render={<option value=""></option>}>Select something</Trans>
      <Trans id="ui.one" render={<option value="1"></option>}>One</Trans>
      <Trans id="ui.two" render={<option value="2"></option>}>Two</Trans>
</Select>
Read more comments on GitHub >

github_iconTop Results From Across the Web

Standard Objects | Object Reference for the ...
Represents the selections made by the user against a specific Ad Quote Line item for a particular category. This object is available in...
Read more >
Object Reference for Salesforce and Lightning Platform
Objects already created for you by Salesforce are called standard ... Multi-select picklist fields contain a list of one or more items from ......
Read more >
5 Things You Should Never Do In A Manual Transmission ...
5 Things You Should Never Do With A Manual Transmission Vehicle. Five bad stick shift driving habits. Is it okay to rest your...
Read more >
Create a Z object in Migration Cockpit – User-Defined
Guide for the creation of an Z object for Migration Cockpit Here we ... With the rule there also Translation Objects, almost all...
Read more >
Manual transmission
In most vehicles with a manual transmission, the driver selects gears by manipulating a lever called a gear stick (also called a gearshift,...
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