1-Chapter-1 - Introduction
1-Chapter-1 - Introduction
1. What is React?
● Library for UI: React is not a full-fledged framework but rather a library
focused on the view layer of an application. It helps you build user
interfaces efficiently.
a. Efficiency: React's virtual DOM and smart diffing algorithm make updates to the
UI efficient. This leads to better performance and a smoother user experience.
c. Ecosystem: React has a rich ecosystem of libraries and tools (e.g., React Router,
Redux) that extend its functionality and make it suitable for building various types
of applications.
d. Large Community: React has a vast and active community, which means plenty
of resources, tutorials, and third-party components are available. You can find
solutions to common issues and stay up to date with best practices.
cd my-react-app
my-react-app/
├── node_modules/ # Dependencies installed by npm
├── public/ # Static assets and HTML template
├── src/ # React application source code
├── package.json # Project configuration and dependencies
├── README.md # Project documentation
Chapter-I Introduction to React
5
- public/ Directory:
- Contains the index.html file, which is the entry point for your React app.
- You can place static assets like images and fonts in this directory.
- src/ Directory:
-
- This is where you will write your React application code.
- The src directory typically contains App.js, which is the root component of
your application.
- You can create additional components in this directory.
- package.json:
- Defines the project's metadata, including dependencies, scripts, and
configuration.
- You can add or update dependencies here.
Development Scripts:
- Locate the App.js file in your project. This file is typically found in the src
directory if you're using the default project structure created by
create-react-app.
- Open the App.js file and replace the existing code with the following:
function App() {
return (
<div>
<h1>Hello, World</h1>
</div>
);
}
And do
npm start
You can see the Hello World in the default port 3000, in your browser from the
following URL :-
http://localhost:3000/
Chapter-I Introduction to React
7
1. React JS Featues