react-i18next icon indicating copy to clipboard operation
react-i18next copied to clipboard

warning when pass a number to Trans values prop

Open mdeljavan opened this issue 1 year ago • 4 comments

🐛 Bug Report

When we pass a number to values of Trans and use it as a child, we get a warning in the console.

To Reproduce

<Trans
  i18nKey="update"
  values={{
    refreshInterval: 12,
  }}
>
  <span>{value}</span>
</Trans>

warning: react-i18next:: Trans: the passed in value is invalid - seems you passed in a variable like {number} - please pass in variables for interpolation as full objects like {{number}}

Expected behavior

I do not have any warning in the console.

Your Environment

  • runtime version: i.e. node v18
  • i18next version: i.e. 23.5.1
  • os: Mac, Windows, Linux

mdeljavan avatar Sep 11 '23 13:09 mdeljavan

I don't know what you mean... and you also did not provide a reproducible example.

adrai avatar Sep 11 '23 13:09 adrai

We have to check type of number in here https://github.com/i18next/react-i18next/blob/1ff5cabcebcc833af8410dc4c69ea08070dda745/src/TransWithoutContext.js#L49

mdeljavan avatar Sep 11 '23 13:09 mdeljavan

feel free to open a pull requests with tests

adrai avatar Sep 11 '23 14:09 adrai

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

stale[bot] avatar Oct 15 '23 11:10 stale[bot]