Skip to content

Type error for tag interpolation when using useTranslate hook #3337

Closed
@Yureien

Description

@Yureien

This is what is stated in the documentation, and works successfully:

const Component = () => {
  return (
    <div>
      <T
        keyName="translation_key"
        params={{ i: <i /> }}
        defaultValue="This is <i>formatted</i>"
      />
    </div>
  );
};

However, this gives a type error with the equivalent useTranslate hook:

const { t } = useTranslate();

const result = t("translation_key", "This is <i>formatted</i>", { i: <i /> });

It seems that the DefaultParamType does not accept JSX.Element types:

export type DefaultParamType = string | number | bigint | Date;

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions