React¶
React is a popular JavaScript library for building user interfaces. It was developed by Facebook and released in 2013. React is often used in single-page applications and is known for its component-based architecture.
Prerequisites¶
Node.js¶
Node.js is an asynchronous event-driven JavaScript runtime, Node.js is designed to build scalable network applications.
-
To install Node.js
Node Package Manager¶
Node.js is all about modularity, and with that comes the need for a quality package manager; for this purpose, npm was made. npm is a package manager for Node.js packages or modules.
-
To install npm
-
To install a packge or module using npm
-
To utilize the precise dependency versions specified in a
package-lock.json
file when installing packages
Getting Started¶
Scaffold a new project¶
Create React App and Vite (my preference) are two of the most popular methods for scaffolding new React projects.
Create React App¶
Vite¶
UI Frameworks¶
Bootstrap¶
-
Install the Bootstrap package
-
Import the Bootstrap object
Material UI¶
-
Install Material UI
Flowbite React¶
-
Install the Flowbite React package
Styling and CSS¶
React uses className
instead of class
is because class
is a reserved keyword in JavaScript, and JSX (the syntax extension used by React) is essentially JavaScript code. JSX allows you to write HTML-like code within JavaScript, but since class
has a specific meaning in JavaScript (used for defining classes), it cannot be used as an attribute name in JSX.
Components¶
Components are independent and reusable bits of code. They serve the same purpose as JavaScript functions, but work in isolation and return HTML.
const Navbar = () => {
return <>{/* Your navbar content goes here */}</>
}
export default Navbar
React Router¶
React Router is a popular library for handling routing in React applications. It allows you to create declarative routing in your React components, enabling navigation between different pages or views within your application.
-
Install React Router
References¶
- HTML
- JavaScript
- TypeScript
- Learn HTML and CSS
- Learn JavaScript
- Learn React
- React Tutorial for Beginners
- Learn React Router
Created: June 4, 2023