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

[Regression] Version 3.1.0 no longer traverses fragments in React 18 #22

Closed
benface opened this issue Jan 21, 2025 · 2 comments
Closed

Comments

@benface
Copy link

benface commented Jan 21, 2025

In React 18, the following code used to render 2 section elements, now it renders a single one:

import flattenChildren from 'react-keyed-flatten-children'

const Component = ({ children, ...props }: ComponentPropsWithoutRef<'div'>) => {
  const childrenArray = flattenChildren(children)
  return <>childrenArray.map((child) => <section>{child}</section>)</>
}

return (
  <Component>
    <>
      <div>First item</div>
      <div>Second item</div>
    </>
  </Component>
)

CodeSandbox

@benface
Copy link
Author

benface commented Jan 28, 2025

@grrowl – I confirm this bug only occurs in React 18. No issues in React 19. I added a repro link to my first post ☝️

@benface benface changed the title [Regression] Version 3.1.0 no longer traverses fragments [Regression] Version 3.1.0 no longer traverses fragments in React 18 Jan 28, 2025
@grrowl
Copy link
Owner

grrowl commented Jan 29, 2025

Thank you! I've reverted the React 19 changes as v3.2.0, and re-published React 19 under v4.0.0, and added a note to the README :)

https://github.com/grrowl/react-keyed-flatten-children/blob/master/README.md?plain=1#L5

@grrowl grrowl closed this as completed Jan 29, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants