Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Confusion between types and documentation for FormattedMessage Function as the child #3117

Closed
ilyagru opened this issue Aug 16, 2021 · 3 comments
Labels

Comments

@ilyagru
Copy link

ilyagru commented Aug 16, 2021

Which package?

Since this is a monorepo. Please specify which package this bug report is for.

react-intl 5.20.8

Describe the bug

A clear and concise description of what the bug is.

There is confusion between

  • TypeScript types and

Screenshot 2021-08-16 at 15 13 47

Screenshot 2021-08-16 at 15 16 18

It seems it should be

children?(nodes: React.ReactNodeArray): React.ReactElement | null;

because otherwise if using it like so

<FormattedMessage
  id="..."
  defaultMessage="..."
  values={{...}}
>
  {(...chunks) => {
    return chunks.map(chunk) => React.cloneElement(chunk, { key: index });
  }}
</FormattedMessage>

might produce an error Element type is invalid: expected a string ... but got undefined.

To Reproduce

Codesandbox URL

Please include a codesandbox URL if possible

Reproducible Steps/Repo

Steps to reproduce the behavior:

  1. Go to '...'
  2. Click on '....'
  3. Scroll down to '....'
  4. See error

Expected behavior

A clear and concise description of what you expected to happen.

Screenshots

If applicable, add screenshots to help explain your problem.

Desktop (please complete the following information):

  • OS: [e.g. iOS]
  • Browser [e.g. chrome, safari]
  • Version [e.g. 22]

Smartphone (please complete the following information):

  • Device: [e.g. iPhone6]
  • OS: [e.g. iOS8.1]
  • Browser [e.g. stock browser, safari]
  • Version [e.g. 22]

Additional context

Add any other context about the problem here.

@ilyagru ilyagru added the bug label Aug 16, 2021
@longlho
Copy link
Member

longlho commented Aug 16, 2021

thanks for reporting, latest version should have the fix for this :)

@ilyagru
Copy link
Author

ilyagru commented Aug 16, 2021

@longlho Awesome, thanks! What is the version which includes the fix?

@longlho
Copy link
Member

longlho commented Aug 16, 2021

react-intl@5.20.9

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants