Program 12 SDC Ayesha
Program 12 SDC Ayesha
registration, login, contact, and about pages involves several steps. Below, I’ll outline
how to set up this application
1. Install Node.js: Make sure you have Node.js installed on your computer. You can download
it from nodejs.org.
cd student-management-system
In the src directory, create a folder named components and add the following files: Registration.js,
Login.js, Contact.js, About.js, and Home.js.
CODE:
src/components/Registration.js
return (
<div>
<h2>Registration Page</h2>
<form>
</form>
</div>
);
};
src/components/Login.js
return (
<div>
<h2>Login Page</h2>
<form>
</form>
</div>
);
};
src/components/Contact.js
return (
<div>
<h2>Contact Page</h2>
</div>
);
};
src/components/About.js
return (
<div>
<h2>About Page</h2>
</div>
);
};
src/components/Home.js
return (
<div>
<h2>Home Page</h2>
</div>
);
};
src/App.js
return (
<Router>
<div>
<nav>
<ul>
<li><Link to="/">Home</Link></li>
<li><Link to="/registration">Registration</Link></li>
<li><Link to="/login">Login</Link></li>
<li><Link to="/contact">Contact</Link></li>
<li><Link to="/about">About</Link></li>
</ul>
</nav>
<Routes>
</Routes>
</div>
</Router>
);
};
npm start
Program 13:
Steps to follow:
1. Press Windows + X and select Windows PowerShell (Admin) or Windows Terminal (Admin)
if you have the updated terminal.
Run the following command to set the execution policy to allow scripts to run:
You might be prompted to confirm the change. Type Y and press Enter
Get-ExecutionPolicy –List
Now that the execution policy is set, you should be able to run the serve command without issues:
serve -s build
If you prefer not to change your execution policy, you can use npx to run serve without globally
installing it
Install Axios for making HTTP requests and Chart.js for creating charts.
3. Install Dependencies:
cd weather-app
Create a new file src/services/weatherService.js and add the following code to fetch weather data:
try {
params: {
q: city,
appid: API_KEY,
units: 'metric',
},
});
return response.data;
} catch (error) {
};
try {
params: {
q: city,
appid: API_KEY,
units: 'metric',
},
});
return response.data;
} catch (error) {
};
Create a new component src/components/Weather.js and add the following code to display the
weather data:
setCurrentWeather(currentData);
setHistoricalWeather(historicalData);
};
fetchWeatherData();
}, [city]);
const data = {
datasets: [
fill: false,
backgroundColor: 'rgba(75,192,192,1)',
borderColor: 'rgba(75,192,192,1)',
},
],
};
return (
<div>
<h1>Weather in {city}</h1>
{currentWeather && (
<div>
<p>Weather: {currentWeather.weather[0].description}</p>
</div>
)}
</div>
);
};
import './App.css';
function App() {
return (
<div className="App">
<header className="App-header">
<h1>Weather App</h1>
</header>
<Weather />
</div>
);
npm start
Program 14:
Create a TODO application in react with necessary components and deploy it into
github. in vs code
Sure, let's create a simple TODO application using React and deploy it to GitHub. Here are the steps:
First, you need to set up a new React project. Open your terminal and run the following commands:
cd todo-app
code .
1. App Component
import './App.css';
function App() {
};
newTodos[index].completed = !newTodos[index].completed;
setTodos(newTodos);
};
newTodos.splice(index, 1);
setTodos(newTodos);
};
return (
<div className="App">
<h1>TODO List</h1>
</div>
);
2. TodoList Component
<ul>
<TodoItem
key={index}
todo={todo}
index={index}
toggleTodo={toggleTodo}
deleteTodo={deleteTodo}
/>
))}
</ul>
);
3. TodoItem Component
return (
<li>
<span
>
{todo.text}
</span>
</li>
);
4. TodoForm Component
e.preventDefault();
if (!value) return;
addTodo(value);
setValue('');
};
return (
<form onSubmit={handleSubmit}>
<input
type="text"
value={value}
/>
<button type="submit">Add</button>
</form>
);
}
export default TodoForm;
The logic for adding, toggling, and deleting TODOs is already implemented in the App component.
Each component is responsible for a specific part of the application:
git init
git add .
2. Create a new repository on GitHub and follow the instructions to push your code. Typically, it will
look something like this:
To deploy your React app to GitHub Pages, you need to install the gh-pages package and add a few
scripts to your package.json.
"homepage": "https://yourusername.github.io/todo-app",