Experiment 6 Observation Format
Experiment 6 Observation Format
Create a ToDO application in react with necessary components and deploy it into github
Aim:
To develop a To-Do application using React and deploy the application on GitHub.
Objective:
Procedure:
Step 1:
Install Node.js from https://nodejs.org/en.
Step 2:
Create the new folder and open in VS Code
Step 3:
Create a new React application using the command:
npx create-react-app todo-app
after that change the directory
cd todo-app
Step 4:
Create a components like App.js, ToDoList.js and write the code
Step 5:
Open the terminal and run the program by typing “npm start”.
Step 6:
Deploy to GitHub:
Initialize a Git repository in the project folder.
Push the project to a new GitHub repository:
git init
git add .
git commit -m "Initial commit"
git branch -M main
git remote add origin https://github.com/<your-username>/<your-repo-name>.git
git push -u origin main
Theory:
React Components
There are two types of components in React.
• Class Components.
• Functional Components.
Class Components:
It Manages state and lifecycle methods.
Sytax:
render() {
Functional Components
It is a simple JavaScript function.
Sytax:
function Welcome(props) {
return <h1>Hello</h1>;
Hooks:
It is used to manage the states and side effects ( previously this is possible only in class components)
Basic Hooks:
• useState()
• useEffect()
• useContext()
useState()
It is used to add state management to functional components.
useState returns an array with two elements the current state value and a function to update
the state.
Syntax
const [state, setState] = useState(initialValue);
initialValue: The initial value of the state, which can be any JavaScript value (like a string,
number, object, array, etc.)
map method in js
map() goes through each item in an array.
Example:
const numbers = [1, 2, 3];
const doubled = numbers.map(num => num * 2);
filter method in js
filter() checks each item in an array.
Example:
const numbers = [1, 2, 3, 4, 5];
const even = numbers.filter(num => num % 2 === 0);
Conclusion: