Skip to content

Commit

Permalink
fix: nullish coalescing operator
Browse files Browse the repository at this point in the history
  • Loading branch information
pdrbrnd committed Dec 9, 2022
1 parent 58bef7d commit fadd177
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 2 deletions.
2 changes: 1 addition & 1 deletion src/Translation.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ export const Translation = ({ id, values = {} }: Props): JSX.Element => {
Record<string, string | React.ReactNode>
>(matches, id, values)
const elements = parts.map((part, i) => {
return <Fragment key={part + i}>{matchedValues[part] || part}</Fragment>
return <Fragment key={part + i}>{matchedValues[part] ?? part}</Fragment>
})

return <Fragment>{elements}</Fragment>
Expand Down
2 changes: 1 addition & 1 deletion src/useTranslation.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ export const useTranslation = () => {

const matchedValues = parseMatchesForKey(matches, key, values)
const elements = parts.map((part) => {
return matchedValues[part] || part
return matchedValues[part] ?? part
})

return Array.isArray(elements) ? elements.join('') : elements
Expand Down

0 comments on commit fadd177

Please sign in to comment.