Welcome-to-React
Welcome-to-React
Use the terminal to navigate and manage your Use create-react-app to create a new React
project files. project, including all the necessary files and
configuration.
1. pwd: Print working directory.
2. ls: List directory contents.
npm install -g create-react-app
3. mkdir: Make directories.
4. cd: Change directory. Then, run create-react-app my-app to create a
5. cd ..: Move up one directory level. new app named "my-app".
Babel and JSX
React.createEleme
nt('div', null, 'Hello,
world!')
Understanding the Folder Structure
package.json App.js
Configuration file for the project, including Entry point for the application. The code here
dependencies and scripts. is the first code that will be executed when
you run the app.
Components and JSX
1 2 3
function Greeting(props) {
if (props.isLoggedIn) {
return <p>Welcome, {props.name}
</p>;
} else {
If-Else Statements return <p>Please log in</p>;
}
Use if-else statements to conditionally render
}
different content.
1 2 3
Ternary Operators
A shorthand for if-else statements, ideal for
concise conditional rendering.
Reserved Keywords and Rules of
Components
Keyword Explanation Example