javascript - How to run SystemJS/React demo locally with JSX? -
i'm following this video tutorial @ moment , i'm stuck simple helloworld app. @ time position 12m:31s i'm stuck should show helloworld doesn't.
the app using systemjs, react , jsx.
to create app these steps in terminal (node , jspm required):
npm init(enterall)jspm init(enterall, except use babel)jspm install fetch=npm:whatwg-fetchjspm install react- create app sub-folder create
main.js, copy code it - create
index.htmlroot dir. - then run serve
i think problem local server. i'm running nodejs http-server , think jsx not transpiled js. mentioned serve server not working.
i'm getting error message in browser console:
potentially unhandled rejection [3] syntaxerror: error loading "app/main" [...] unexpected token < how make work?
here code, code video (it doesn't run here because no js files added):
//app/main.js import 'fetch'; import react 'react'; console.log('hello world'); class helloworld extends react.component { render() { return <p>hello world</p>; } } react.render(<helloworld />, document.body); <!-- index.html --> <!doctype html> <html> <head> <title>first jspm</title> <script type="text/javascript" src="jspm_packages/system.js"></script> <script type="text/javascript" src="config.js"></script> <script> system.import('app/main'); </script> </head> <body> </body> </html>
i have no idea tutorial, jsx needs have jsx transpiler included before jsx files loaded. looks script tags have type="text/jsx" compile regular javascript.
it sound's tutorial may have complicated matter.
Comments
Post a Comment