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

Inconsistency between how inferno and inferno-server handles components returning arrays #1501

Closed
jhsware opened this issue Jan 23, 2020 · 5 comments · Fixed by #1503
Closed
Labels

Comments

@jhsware
Copy link
Contributor

jhsware commented Jan 23, 2020

If an inferno component returns a literal array the DOM-library will render it using "mountArrayChildren", but inferno-server will throw the error "renderToString() received an object that's not a valid VNode".

Is this a bug in inferno-server or inferno?

i.e.

class MyComp extends Component {
  render() {
    return [<p>foo</p>, <p>bar</p>]
  }
}

Would render in the browser, but not on the server. Swapping array to a fragment (<></>) solves this issue.

@Havunen Havunen added the bug label Jan 23, 2020
@Havunen
Copy link
Member

Havunen commented Jan 23, 2020

This seems like bug. Thanks for reporting it.

@jhsware
Copy link
Contributor Author

jhsware commented Jan 24, 2020

@Havunen what is the intended behaviour? Should I see if I can suggest a fix?

@Havunen
Copy link
Member

Havunen commented Jan 27, 2020

@jhsware Sure, basically arrays should be handled same way as fragments. See non-server side code:

https://github.com/infernojs/inferno/blob/master/packages/inferno/src/core/implementation.ts#L400-L402

I think server side could just jump into rendering children logic flow? Note that test cases needs to be added for all these 3 methods:

https://github.com/infernojs/inferno/blob/master/packages/inferno-server/src/index.ts#L9-L14

@jhsware
Copy link
Contributor Author

jhsware commented Jan 27, 2020

@Havunen okay great, yeah I'll start by adding tests. Will see if I can figure it out Tomorrow.

@Havunen
Copy link
Member

Havunen commented Jan 28, 2020

7.4.0 published

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

Successfully merging a pull request may close this issue.

2 participants