babel-plugin-react-intl-auto icon indicating copy to clipboard operation
babel-plugin-react-intl-auto copied to clipboard

Ids are missing if the FormattedMessage uses the same defaultMessage

Open scottdickerson opened this issue 5 years ago • 0 comments

  • version: 3.3.0
  • node version:
  • npm (or yarn) version:

Do you want to request a feature or report a bug?: Bug

What is the current behavior?: For FormattedMessage if the FormattedMessage is placed directly inside a span, the ID fails to generate for the second component and react-intl will throw the invariant missing ID message when the component is rendered.

This should reproduce the error

<span>
<FormattedMessage defaultMessage='Hi There' />
</span>

What is the expected behavior?: All FormattedMessages would successfully generate an ID

Suggested solution: I've worked around this by hardcoding an id in the specific messages that were failing to generate an ID or by using <FormattedMessage tagName="span"/>

scottdickerson avatar Apr 07 '20 20:04 scottdickerson