Code Monkey home page Code Monkey logo

Comments (3)

adrai avatar adrai commented on June 1, 2024 1

The components passed do not need to handle the children...
so try:

      <Trans
        i18nKey="user.login"
        ns="global"
        components={{
          loginCTA: (
            <a
              href="https://www.google.com"
              target="_blank"
              rel="noreferrer"
              className="underline text-brand-blue100"
            />
          ),
        }}
      />

from react-i18next.

Frankusky avatar Frankusky commented on June 1, 2024

So a workaround that I did is to create a component to wrap the anchor tag.

const LinkTo = ({ children, href }: { children: any; href: string }) => {
  return (
    <a
      href={href}
      target="_blank"
      rel="noreferrer"
      className="underline text-brand-blue100"
    >
      {children}
    </a>
  );
};

Then pass it to the Trans component

<Trans
  i18nKey="user.login
  ns="global"
  components={{
    login: (
      <LinkTo href="https://google.com" />
    )
  }}
/>

Is there any way to avoid to create a new component just to wrap the anchor tag?

from react-i18next.

Frankusky avatar Frankusky commented on June 1, 2024

😲 oh that is working, thanks!

from react-i18next.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.