Closed andrewatliferay closed 4 years ago
You should configure your .babelrc
file correctly. The JS Toolkit is not responsible to transpiling your source code: it is done as a build step prior to executing liferay-npm-bundler
.
Hi Ivan,
Thanks for the details -- something else to figure out hahah (I'm newish to all this). One more comment though. According to documentation I found, the React framework added this shorthand notation in 16.2. The liferay-js tools generated for me a skeleton project with 16.8 as the version so I would argue that developers might expect to be able to use it (just based on versions).
Can the necessary babelrc changes be added as part of the generated skeleton project?
Hi again. After thinking more about it, I'm unsure if the shorthand notation is a matter of tweaking the .babelrc
file, as everything you are supposed to put there is the react preset and it is there by default :thinking:
As you say, fragments are available since 16.2 so I have to investigate this a bit more...
Found it. This is the reason.
You need Babel 7 for the shorthand </>
notation to work and we still use Babel 6. So, the only workaround for now is to use <React.Fragment>
I can confirm that using does allow me to leverage the fragment in the markup, but when I try to use the shorthand notation <></> in my return markup I get an error:
SyntaxError: src/components/Comments.js: Unexpected token (36:13) 34 | else 35 | return(