Observed Behaviour
Inferno is producing an error when using Provider from inferno-mobx in hyperscript:
Inferno Error: a valid Inferno VNode (or null) must be returned from a component render. You may have returned an array or an invalid object.
The offending code snippet:
Inferno.render(
h(Provider, {ls},[
h('div', ls.map((l) => h(ConnectedComponent, {l})))
])
Full example:
```
import Inferno from 'inferno'
import { connect, Provider } from 'inferno-mobx'
import { observable } from 'mobx'
import h from 'inferno-hyperscript';
var ConnectedComponent = connect(['ls'], function({l}){
return h('div', [
h('p', l.title),
]);
});
const ls = observable([
observable({
language: 'english',
title: 'Hello World'
}),
observable({
language: 'french',
title: 'Bonjour tout le monde'
})
])
Inferno.render(
h(Provider, {ls},[
h('div', ls.map((l) => h(ConnectedComponent, {l})))
])
, document.getElementById('main'))
```
Expected Current Behaviour
Inferno should not produce an error.
Inferno Metadata
Linux/Chromium
Thank you!
@briansakal As render function. In this case, you're providing an array, and a component can't return an array. In this case, ensure the direct descendant of
Inferno.render(
h(Provider, {ls},
h('div', ls.map((l) => h(ConnectedComponent, {l})))
), document.getElementById('main'));
I'm hesitant at calling this an error since you'd get the same behavior from the createElement API.
That makes perfect sense, I didn't know what Provider did internally. I treated it as any other Component because that's how I saw it used in JSX style, so I figured in hyperscript I should treat it like an other Component. Should I close the issue?
Good to hear you got it sorted out. Closing :)
Hi @Havunen, I get the same error as @briansakal when using JSX and following the example from the docs... https://infernojs.org/docs/api/inferno-mobx
Any ideas why?
Thanks
Urgh 馃檮 scrap that!! My mistake!
I added the connect function to the wrong component. It's too early in the morning 馃槀
Most helpful comment
@briansakal As doesn't render anything, it seemly returns its children from the is singular.
renderfunction. In this case, you're providing an array, and a component can't return an array. In this case, ensure the direct descendant ofI'm hesitant at calling this an error since you'd get the same behavior from the
createElementAPI.