P粉7627302052023-08-16 00:19:42
As far as the final result is concerned, there is no difference. Performance-wise, however, the former is slightly faster. But the restriction is that child elements must be text only. There may be situations where you want the text and other content as child elements. In this case you can use createTextVNode()
with one of the appropriate flags, one of which is $HasVNodeChildren
. You can see the list of flags in the documentation: https://www.infernojs.org/docs/guides/optimizations
As an additional note, you don't have to define the shape of the child elements yourself if the compiler can see it at compile time. Therefore, there is no need to write like this:
function Hello() { return <p $HasTextChildren>Hello</p>; }
You can simply write:
function Hello() { return <p>Hello</p>; }