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

cloneElement with props defined does not render correctly #4753

Closed
1 task
craig-jennings opened this issue Sep 14, 2022 · 1 comment · Fixed by #4756
Closed
1 task

cloneElement with props defined does not render correctly #4753

craig-jennings opened this issue Sep 14, 2022 · 1 comment · Fixed by #4756
Assignees
Labels
- P4: important Violate documented behavior or significantly impacts performance (priority)

Comments

@craig-jennings
Copy link

What version of astro are you using?

1.2.3

Are you using an SSR adapter? If so, which one?

None

What package manager are you using?

npm

What operating system are you using?

Windows

Describe the Bug

When using cloneElement in a React component, passing anything to the optional props parameter causes the children of the cloned element to not render.

Here's a screenshot of the DOM rendered in the linked StackBlitz example. Notice that the div of the ClonedWithProps component is rendered but not it's children, while the ClonedWithoutProps children are rendered correctly.

image

The only difference between the two components is that one calls cloneElement(element, props) while the other only calls cloneElement(element)

Link to Minimal Reproducible Example

https://stackblitz.com/edit/github-wysfgw?file=src/pages/index.astro

Participation

  • I am willing to submit a pull request for this issue.
@matthewp
Copy link
Contributor

Looks like React doesn't like passing null or undefined as the children prop is the reason.

@matthewp matthewp added the - P4: important Violate documented behavior or significantly impacts performance (priority) label Sep 14, 2022
@matthewp matthewp self-assigned this Sep 14, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
- P4: important Violate documented behavior or significantly impacts performance (priority)
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants