-
Notifications
You must be signed in to change notification settings - Fork 27.7k
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
Usage of React.Fragment in Container causes Inferno incompatability #4681
Comments
Intermediate quickfix is to override pages/_app.js import App, { Container, createUrl } from 'next/app'
import React from 'react'
class MyContainer extends Container {
render () {
const {children} = this.props
// make sure to support all React-like libraries, whether they support Arrays, React.Fragment or not
if (Array.isArray(children)) {
console.log('Children is an array');
// a root node is necessary
return <div>{children.map((child, index) => {
// only set key if it's null or undefined
if (child.key == null) {
child.key = index
}
console.log(`${child.key} -> ${index}`)
return child
})}</div>
}
return children
}
}
export default class MyApp extends App {
render () {
const {router, Component, pageProps} = this.props
const url = createUrl(router)
return <MyContainer>
<Component {...pageProps} url={url} />
</MyContainer>
}
} |
I did bit some more research and I find out that Which may could be set to a "plugins": [
["transform-react-jsx", {
"pragma": "h",
"pragmaFrag": "\"div\""
}]
] Related issue of Preact: |
This issue has been resolved in #4766 |
Bug report
First, really thanks a lot for this awesome piece of software 😃
Describe the bug
The
Container
'srender
method does not need to be wrapped byReact.Fragment
.Just returning
children
is enough, if only one children is ever used.Are multiple
children
ever considered to be used?Since Inferno does not support Fragments yet, this also breaks the inferno example.
To Reproduce
Steps to reproduce the behavior, please provide code snippets or a repository:
inferno-clone-vnode
,inferno-create-class
andinferno-create-element
Expected behavior
Inferno should work and unnecessary Fragments should not be used.
System information
6.0.3
Additional context
Related issue: #4031
The text was updated successfully, but these errors were encountered: