Skip to content

Commit

Permalink
fix: macro components should omit key prop #994
Browse files Browse the repository at this point in the history
  • Loading branch information
Sergio Moreno committed Mar 4, 2021
1 parent 60293c8 commit f2a4da0
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 0 deletions.
28 changes: 28 additions & 0 deletions packages/macro/src/macroJsx.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -139,6 +139,34 @@ describe("jsx macro", () => {
})
})

it("plural with key should be omitted", () => {
const macro = createMacro()
const exp = parseExpression(
`<Plural
key='somePLural'
value={count}
_0='No books'
one='# book'
other='# books'
/>`
)
const tokens = macro.tokenizeChoiceComponent(exp)
expect(tokens).toEqual({
type: "arg",
name: "count",
value: expect.objectContaining({
name: "count",
type: "Identifier",
}),
format: "plural",
options: {
"=0": "No books",
one: "# book",
other: "# books",
},
})
})

it("plural with template literal", () => {
const macro = createMacro()
const exp = parseExpression(
Expand Down
1 change: 1 addition & 0 deletions packages/macro/src/macroJsx.ts
Original file line number Diff line number Diff line change
Expand Up @@ -273,6 +273,7 @@ export default class MacroJSX {
ID,
COMMENT,
MESSAGE,
"key",
// we remove <Trans /> react props that are not useful for translation
"render",
"component",
Expand Down

1 comment on commit f2a4da0

@vercel
Copy link

@vercel vercel bot commented on f2a4da0 Mar 4, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.