Let's build our first React application by following these steps:
- Create our React application with the following command:
create-react-app my-first-react-app
- Go to the new application with cd my-first-react-app and start it with npm start.
- The application should now be running at http://localhost:3000.
- Create a new file called Home.js inside your src folder:
import React, { Component } from 'react';class Home extends Component { render() { return <h1>I'm Home Component</h1>; }}export default Home;
File: src/Home.js
- You may have noticed that we are exporting our class component at the end of the file, but it's fine to export it directly on the class declaration, like this:
import React, { Component } from 'react'; ...