Skip to content

Commit

Permalink
fix: preserve component prop on Trans
Browse files Browse the repository at this point in the history
  • Loading branch information
vonovak authored and thekip committed May 30, 2024
1 parent 66bd99c commit c318352
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
4 changes: 2 additions & 2 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -97,11 +97,11 @@ impl LinguiMacroFolder {
}

attrs.extend(
pick_jsx_attrs(el.opening.attrs, HashSet::from(["id", "render", "i18n"]))
pick_jsx_attrs(el.opening.attrs, HashSet::from(["id", "component", "render", "i18n"]))
);

if self.ctx.options.strip_non_essential_fields {
attrs = pick_jsx_attrs(attrs, HashSet::from(["id", "render", "i18n", "values", "components"]))
attrs = pick_jsx_attrs(attrs, HashSet::from(["id", "component", "render", "i18n", "values", "components"]))
}

self.ctx.should_add_trans_import = true;
Expand Down
4 changes: 2 additions & 2 deletions src/tests/jsx.rs
Original file line number Diff line number Diff line change
Expand Up @@ -47,11 +47,11 @@ to!(
jsx_preserve_reserved_attrs,
r#"
import { Trans } from "@lingui/macro";
const exp2 = <Trans comment="Translators Comment" context="Message Context" i18n="i18n" render={(v) => v}>Refresh inbox</Trans>;
const exp2 = <Trans comment="Translators Comment" context="Message Context" i18n="i18n" component={(p) => <div>{p.translation}</div>} render={(v) => v}>Refresh inbox</Trans>;
"#,
r#"
import { Trans } from "@lingui/react";
const exp2 = <Trans message={"Refresh inbox"} id={"6J8UtY"} i18n="i18n" render={(v) => v} />
const exp2 = <Trans message={"Refresh inbox"} id={"6J8UtY"} i18n="i18n" component={(p) => <div>{p.translation}</div>} render={(v) => v} />
"#
);

Expand Down

0 comments on commit c318352

Please sign in to comment.