You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
It might be the way I render the child components:
// this failsrender(){returnthis.values.map(value=>{return<div>{value.value}</div>;});}// this worksrender2(){consta=this.values.map(value=>{return<div>{value.value}</div>;});return(<main>{a}</main>);}
I think it's because you try to return an array of JSX element in your first example.
In my experience, when you try to return an array of JSX elements with React, you get the following error: Adjacent JSX elements must be wrapped in an enclosing tag
In your case and because you're not using react, you should try to wrap what you return in another JSX element just like you did in render2().
Activity
dimi-nk commentedon Apr 12, 2018
It might be the way I render the child components:
jgw96 commentedon Apr 12, 2018
Hello! Thanks for using Stencil. I am not able to reproduce this issue with the latest version of Stencil. I would recommend updating to 0.7.20.
dimi-nk commentedon Apr 12, 2018
I can still see this issue after updating
doliG commentedon Apr 12, 2018
Hello @dimi-nk ,
I think it's because you try to return an array of JSX element in your first example.
In my experience, when you try to return an array of JSX elements with React, you get the following error:
Adjacent JSX elements must be wrapped in an enclosing tagIn your case and because you're not using react, you should try to wrap what you return in another JSX element just like you did in
render2().I think something like this should work:
Note that there is no need to use return in an arrow function (except if you find it's better for readability 😉).
I suggest you these readings:
https://reactjs.org/docs/fragments.html
https://codeburst.io/fragment-in-react-1cd69f158910
Let me know if it helps 😊
dimi-nk commentedon Apr 12, 2018
Hey @doliG thanks for the info (I know the arrow fn part 😂 ).
I have a few cases in stencil components where I do this (and it works just fine):
example

Any ideas?
juanmiguelbesada commentedon Apr 13, 2018
I still can reproduce this issue in 0.7.24
jgw96 commentedon Apr 19, 2018
Hello all! We are currently refactoring slots which should fix this issue. I will give this another test once that is done.