Create ReactJS Project
Create new folder named LearnReactJSWithRealApps and select to this folder in Visual Studio Code
Open Terminal windows in Visual Studio Code and use commands below:
npm install create-react-app@latest
npx create-react-app myapp
Create New Component
Open App.js file in src folder and create new component as below:
import React, { useEffect } from 'react';
function App() {
useEffect(() => {
console.log('Component Did Mount');
});
return (
<div>
<h3>Component's LifeCycle</h3>
</div>
);
};
export default App;
Add Component to Entry File
Open index.js file in src folder and add new component to this file as below:
import React from 'react';
import ReactDOM from 'react-dom';
import './index.css';
import App from './App';
import * as serviceWorker from './serviceWorker';
ReactDOM.render(<App />, document.getElementById('root'));
serviceWorker.unregister();
Structure of Project
Run Application
In Terminal windows in Visual Studio Code and type: npm start,
program will open url http://localhost:3000 on browser