What is React?

Install Node.js

To use React in production, you need npm which is included with Node.js.

What is Node.js?

Node.js is an open-source, cross-platform JavaScript runtime environment that allows developers to run JavaScript outside the browser. It is primarily used for server-side development, making it possible to create fast, scalable, and real-time applications.

Before Node.js, JavaScript could only run inside a web browser (like Chrome or Firefox). Node.js changed that by allowing JavaScript to run on a server, enabling backend development with JavaScript.

What is npm (Node Package Manager)?

npm (Node Package Manager) is the default package manager for Node.js. It helps developers install, manage, and share JavaScript libraries and tools easily.

Steps to Install Node.js:

Create a React App

React Project Structure

src/ → This is the Core Folder for Your React Code:

App.js → This is the main component of Your React App

This is the primary file where you write your React code. It serves as the main component of your application, and you can:
  • Create and modify the UI.
  • Import and use other components.
  • Add styles and logic.
  • React Image Import Methods

    Method When to Use Example
    Import (import logo from './logo.svg') When using images inside src/ <img src={logo} />
    Direct Path (src="/logo.svg") When using images inside public/ <img src="/logo.svg" />
    External URL For online images <img src="https://example.com/image.jpg" />

    Check React Version Using npm

    Execute this command in the terminal within your project directory:
    	npm list react
    	

    React Comment Syntax Summary

    Type Syntax Where to Use?
    Single-line JavaScript comment // This is a comment Outside JSX
    Multi-line JavaScript comment /* This is a comment */ Outside JSX
    JSX Comment {/* This is a JSX comment */} Inside JSX

    What is JSX? (JavaScript XML)

    JSX (JavaScript XML) is a syntax extension for JavaScript that allows you to write HTML-like code inside JavaScript files. It is used in React to describe what the UI should look like.