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.

[V3] Trans is eating up parent component

See original GitHub issue

Describe the bug I think that screenshots will explain my issue better…

this Screenshot_2020-10-22_18-15-20

renders to Screenshot_2020-10-22_18-15-46

but

this Screenshot_2020-10-22_18-14-13 renders to Screenshot_2020-10-22_18-14-33

So, it’s, somehow, eating the anchor element, wtf?

I am using the Trans from @lingui/macro.

Expected behavior It shouldn’t eat parent components

Additional context It’s a nextjs app with TS4 and node 14

  • jsLingui version 3.0.20
  • Babel version 7.7.7
  • .babelrc
{
  "env": {
    "production": {
      "presets": ["next/babel", "@emotion/babel-preset-css-prop"],
      "plugins": ["emotion", "macros"]
    },
    "development": {
      "presets": ["next/babel", "@emotion/babel-preset-css-prop"],
      "plugins": [["emotion", { "sourceMap": true }], "macros"]
    }
  }
}

Issue Analytics

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

github_iconTop GitHub Comments

1reaction
tricoder42commented, Oct 23, 2020

No, it’s Link from nextjs.

Not sure what version you use, but Next.js recommends to always use <a> as a child of <Link>. In fact, there several props to handle cases when child component renders <a> on it’s own: https://nextjs.org/docs/api-reference/next/link

EDIT: Next.js should display a warning if you use string as a child of Link:

https://github.com/vercel/next.js/blob/1925ca039c11f8e8cb4d60f973861008e14bee01/packages/next/client/link.tsx#L298-L301

Anyway, glad we get to the bottom of this 👍

0reactions
lucax88xcommented, Oct 23, 2020

They both render a string.

The point is another one.

If Link has a text, it will render an anchor with text, otherwise it will just render the children component, weird stuff.

Not your problem. Infact, it was quite impossible that a child component like Trans could eat a parent, but I was wondering maybe the macro was doing something wrong… but no, Link fault.

Read more comments on GitHub >

github_iconTop Results From Across the Web

is there any way to access the parent component instance in ...
I've already built a transpiler that modifies the output jsx to achieve this. I do this by passing in parent={this} in all child...
Read more >
How to pass data from child component to its parent in ReactJS
Following are the steps to pass data from child component to parent component: In the parent component, create a callback function.
Read more >
Angular components: How to talk to your children and listen to ...
Open the app.component.html file and remove the content. We'll be replacing it with other stuff as we progress. Parent and child components.
Read more >
Fears about HIV Transmission in Families with an HIV-Infected ...
Few studies have examined whether families with an HIV-infected parent experience fears about transmission to children and how they address ...
Read more >
Understanding the Transgender Community
As trans people become more visible, we aim to increase understanding of our community among our friends, families, and society. What does it...
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