Hello, I’m new in react. So, now I know how to create react app using inline method which is using <script type="text/babel"> tag and literal react code inside its html code and it works perfectly in my browser.
Now I want to separate the react app into another file (.js) in the same folder and using external method. I tried to insert <script src='app.js'></script> in my main html file but it won’t load in my browser (mozilla and chrome). So what did I do wrong? thanks
Im having similar problems…my app doesnt seem to like rendering the html. Hopefully you find out whats going on, I just wanted to say that if your importing react then you do not need react.component. You can just use
import React, { Component } from 'react';
and then
class app extends Component {
render() {
return ( returning whatever here
To use the JSX syntax those files must be compiled (translated), so that the browser can understand them.
You can follow those instructions to setup a development environment.
If you want to avoid using those tools you can however write React without using JSX.
Internally the code from above is converted to something like that.
Thank you! I learned a lot… I decided to use node.js and run npm create-react-app in command prompt to do the magic. Just like what you’d say that JSX needs to be compiled, babel handle this thing in the backstage. nice tips and refferences! thank you again!
Appreciate it. I’m actually using cloud9 now. Set up with node.js. I actually ran across it from a udemy course im also taking. Glad you got it resolved.