Skip to content
geeksforgeeks
  • Courses
    • DSA to Development
    • Get IBM Certification
    • Newly Launched!
      • Master Django Framework
      • Become AWS Certified
    • For Working Professionals
      • Interview 101: DSA & System Design
      • Data Science Training Program
      • JAVA Backend Development (Live)
      • DevOps Engineering (LIVE)
      • Data Structures & Algorithms in Python
    • For Students
      • Placement Preparation Course
      • Data Science (Live)
      • Data Structure & Algorithm-Self Paced (C++/JAVA)
      • Master Competitive Programming (Live)
      • Full Stack Development with React & Node JS (Live)
    • Full Stack Development
    • Data Science Program
    • All Courses
  • Tutorials
    • Data Structures & Algorithms
    • ML & Data Science
    • Interview Corner
    • Programming Languages
    • Web Development
    • CS Subjects
    • DevOps And Linux
    • School Learning
  • Practice
    • Build your AI Agent
    • GfG 160
    • Problem of the Day
    • Practice Coding Problems
    • GfG SDE Sheet
  • Contests
    • Accenture Hackathon (Ending Soon!)
    • GfG Weekly [Rated Contest]
    • Job-A-Thon Hiring Challenge
    • All Contests and Events
  • React Tutorial
  • React Exercise
  • React Basic Concepts
  • React Components
  • React Props
  • React Hooks
  • React Router
  • React Advanced
  • React Examples
  • React Interview Questions
  • React Projects
  • Next.js Tutorial
  • React Bootstrap
  • React Material UI
  • React Ant Design
  • React Desktop
  • React Rebass
  • React Blueprint
  • JavaScript
  • Web Technology
Open In App
Next Article:
Expense Tracker using React
Next article icon

Task Scheduler using React

Last Updated : 24 Apr, 2025
Comments
Improve
Suggest changes
Like Article
Like
Report

Task Schedular is an application that saves tasks submitted by the user and categorizes them among low, middle, or high priority. The user can also provide a deadline for the task. The user can also mark a task as completed by clicking on the button, and it will be added to the completed task area.

Preview of Final Output: Let us have a look at how the final application will look like.

Task-Scheduler-using-React-Js

Prerequisite and Technologies Used for Task Scheduler:

  • React
  • CSS
  • Class Components in React
  • React Hooks

Approach to create the Task Scheduler:

  • React's use­State hook effectively manages several ke­y state variables relate­d to tasks. These include upcoming tasks, comple­ted tasks, task names, task priority, and task deadline­.
  • The functions handle­TaskChange, handlePriorityChange, and handle­DeadlineChange capture­ the input provided by the use­rs and subsequently update the­ relevant state variable­s
  • The addTask function performs several tasks. First, it validates the inputs for the task and deadline. If the conditions are met, it procee­ds to create a new task obje­ct. This object is then appende­d to the tasks list.
  • Task state­s are updated by markDone whenever users click on "Mark Done­." This action changes the status of the task and moves completed tasks to the category called completedTasks.
  • The upcomingTasks filters uncomple­ted tasks and presents the­m in a table-like format. The display includes task name, priority, deadline, and a "Mark Done­" button.

Steps to Create the Task Scheduler:

Step 1: Create a react application by using this command

npx create-react-app  task-scheduler-app

Step 2: After creating your project folder, i.e. task-scheduler-app, use the following command to navigate to it:

cd task-scheduler-app

Project Structure:

The updated dependecies in package.json file will look like

"dependencies": {
"@testing-library/jest-dom": "^5.17.0",
"@testing-library/react": "^13.4.0",
"@testing-library/user-event": "^13.5.0",
"react": "^18.2.0",
"react-dom": "^18.2.0",
"react-scripts": "5.0.1",
"web-vitals": "^2.1.4"
}

Example: Write the below code in App.js file and App.css in the src directory

JavaScript
import React, { useState } from "react"; import "./App.css"; // Import your CSS file here  function App() {     const [tasks, setTasks] = useState([]);     const [completedTasks, setCompletedTasks] = useState([]);     const [task, setTask] = useState("");     const [priority, setPriority] = useState("top");     const [deadline, setDeadline] = useState("");      const handleTaskChange = (e) => {         setTask(e.target.value);     };      const handlePriorityChange = (e) => {         setPriority(e.target.value);     };      const handleDeadlineChange = (e) => {         setDeadline(e.target.value);     };      const addTask = () => {         if (task.trim() === "" || deadline === "") {             alert("Please enter a task and select a valid deadline.");             return;         }          const selectedDate = new Date(deadline);         const currentDate = new Date();          if (selectedDate <= currentDate) {             alert("Please select a future date for the deadline.");             return;         }          const newTask = {             id: tasks.length + 1,             task,             priority,             deadline,             done: false,         };          setTasks([...tasks, newTask]);          setTask("");         setPriority("top");         setDeadline("");     };      const markDone = (id) => {         const updatedTasks = tasks.map((t) =>             t.id === id ? { ...t, done: true } : t         );         setTasks(updatedTasks);          const completedTask = tasks.find((t) => t.id === id);         if (completedTask) {             setCompletedTasks([...completedTasks, completedTask]);         }     };      const upcomingTasks = tasks.filter((t) => !t.done);      return (         <div className="App">             <header>                 <h1>Task Scheduler</h1>             </header>             <main>                 <div className="task-form">                     <input                         type="text"                         id="task"                         placeholder="Enter task..."                         value={task}                         onChange={handleTaskChange}                     />                     <select                         id="priority"                         value={priority}                         onChange={handlePriorityChange}                     >                         <option value="top">Top Priority</option>                         <option value="middle">Middle Priority</option>                         <option value="low">Less Priority</option>                     </select>                     <input                         type="date"                         id="deadline"                         value={deadline}                         onChange={handleDeadlineChange}                     />                     <button id="add-task" onClick={addTask}>                         Add Task                     </button>                 </div>                 <h2 className="heading">Upcoming Tasks</h2>                 <div className="task-list" id="task-list">                     <table>                         <thead>                             <tr>                                 <th>Task Name</th>                                 <th>Priority</th>                                 <th>Deadline</th>                                 <th>Action</th>                             </tr>                         </thead>                         <tbody>                             {upcomingTasks.map((t) => (                                 <tr key={t.id}>                                     <td>{t.task}</td>                                     <td>{t.priority}</td>                                     <td>{t.deadline}</td>                                     <td>                                         {!t.done && (                                             <button                                                 className="mark-done"                                                 onClick={() => markDone(t.id)}                                             >                                                 Mark Done                                             </button>                                         )}                                     </td>                                 </tr>                             ))}                         </tbody>                     </table>                 </div>                 <div className="completed-task-list">                     <h2 className="cheading">Completed Tasks</h2>                     <table>                         <thead>                             <tr>                                 <th>Task Name</th>                                 <th>Priority</th>                                 <th>Deadline</th>                             </tr>                         </thead>                         <tbody>                             {completedTasks.map((ct) => (                                 <tr key={ct.id}>                                     <td>{ct.task}</td>                                     <td>{ct.priority}</td>                                     <td>{ct.deadline}</td>                                 </tr>                             ))}                         </tbody>                     </table>                 </div>             </main>         </div>     ); }  export default App; 
CSS
/* App.css */ * {     margin: 0;     padding: 0;     box-sizing: border-box; }  body {     font-family: Arial, sans-serif;     background-color: #f0f0f0;     margin: 0;     padding: 0;     color: #333; }  header {     background-color: white;     color: green;     text-align: center;     padding: 1rem 0;     box-shadow: 0 4px 18px grey; }  main {     max-width: 800px;     margin: 20px auto;     padding: 20px;     background-color: #fff;     box-shadow: 0 4px 18px grey;     border-radius: 15px; }  .task-form {     display: flex;     flex-wrap: wrap;     gap: 10px;     margin-bottom: 20px; }  .task-form input, .task-form select, .task-form button {     padding: 10px;     border: 1px solid #ccc;     font-size: 16px;     flex: 1;     border-radius: 10px; }  button {     background-color: green;     color: white;     border: none;     cursor: pointer; }  .mark-done {     padding: 10px;     font-size: 16px;     flex: 1;     border-radius: 15px;     background-color: crimson;     color: white;     border: none;     cursor: pointer; }  .task-list {     border: 1px solid #ddd;     padding: 10px; }  table {     width: 100%;     margin-top: 20px;     background-color: #fff;     border: 1px solid #ddd; }  table th, table td {     padding: 19px;     border-bottom: 1px solid #ddd;     text-align: left; }  table th {     background-color: #eee;     color: black;     border-radius: 10px; }  .completed-task-list {     margin-top: 20px; }  .completed-task {     padding: 10px;     border: 1px solid crimson;     border-radius: 5px;     background-color: #eaffea; }  .completed-task h2 {     color: #28a745; }  h2 {     font-size: 1.3rem; }  .heading {     padding-bottom: 10px; }  .cheading {     color: rgb(54, 54, 54); } 

Steps to run the Application:

Step 1: Type the following command in the terminal:

npm start

Step 2: Type the following URL in the browser:

 http://localhost:3000/

Output:

Task-Scheduler-using-React-Js


Next Article
Expense Tracker using React
author
saurabhkumarsharma05
Improve
Article Tags :
  • Project
  • Web Technologies
  • ReactJS
  • Geeks Premier League
  • Web Development Projects
  • ReactJS-Projects
  • Geeks Premier League 2023

Similar Reads

  • Typing Speed Tester using React
    In this article, we will create a Typing Speed Tester that provides a random paragraph for the user to type as accurately and quickly as possible within a fixed time limit of one minute. This application also displays the time remaining, counts mistakes calculates the words per minute and characters
    9 min read
  • Storybook Using React
    Storybook is an open-source tool to build the UI components individually, allowing developers to concentrate on one component at a time, examine it more deeply, and record its behavior and changes. The objective of the project is to increase the effectiveness of the development of React components b
    4 min read
  • Tenzies Game using ReactJS
    In this article, we are going to implement Tenzied Games using React JS. Tenzies is a fast-paced and fun game where players have to race to roll a specific combination with a set of ten dice. As we are building this game with ReactJS, we are using the functional components to build the application,
    7 min read
  • Expense Tracker using React
    The Expense Tracker project is a web application developed using React. Its main purpose is to assist users in keeping track of their expenses. With this app, users can easily add, and delete expenses to view a summary of their spending habits as well and it will show the available balance the user
    7 min read
  • Survey Website using ReactJS
    In this article, we will create a survey website template using ReactJS. This project basically creates a single page website which will take input from user in multiple states and stores it to be displayed later. The user has to enter basic details like name, email-Id and contact number. After fill
    10 min read
  • Math Sprint Game using React
    In this article, we will create a Math Sprint Game Using ReactJS. Math Sprint is a fun and challenging game where players have to solve math problems within a time limit to earn points. This game presents random math questions with four options. Players click the correct answer, and if correct, it’s
    5 min read
  • React Router Tutorial
    React Router is a standard library for routing in React. It enables the navigation among views of various components in a React Application, allows changing the browser URL, and keeps the UI in sync with the URL. With React Router, you can create a single-page application (SPA) with multiple "pages"
    3 min read
  • Task Manager App using MERN Stack
    Task Manager is very crucial to manage your tasks. In this article, we are going to develop a task manager application using the MERN stack. This application helps users to manage their tasks efficiently, offering essential features like creating new tasks, editing existing ones, and deleting tasks
    10 min read
  • Create a To-Do List App using React Redux
    A To-Do list allows users to manage their tasks by adding, removing, and toggling the completion status for each added item. It emphasizes a clean architecture, with Redux state management and React interface rendering. Prerequisites Node.jsReactReact-ReduxApproachCreate a new React project using Cr
    3 min read
  • Create a Task Manager App using React-Native
    In this article, we'll walk you through the process of building a basic Task Manager app using React Native. The application enables users to effortlessly create, edit, complete/incomplete, and delete­ tasks, providing an uncomplicated yet impactful introduction to Re­act Native's mobile app develop
    7 min read
geeksforgeeks-footer-logo
Corporate & Communications Address:
A-143, 7th Floor, Sovereign Corporate Tower, Sector- 136, Noida, Uttar Pradesh (201305)
Registered Address:
K 061, Tower K, Gulshan Vivante Apartment, Sector 137, Noida, Gautam Buddh Nagar, Uttar Pradesh, 201305
GFG App on Play Store GFG App on App Store
Advertise with us
  • Company
  • About Us
  • Legal
  • Privacy Policy
  • In Media
  • Contact Us
  • Advertise with us
  • GFG Corporate Solution
  • Placement Training Program
  • Languages
  • Python
  • Java
  • C++
  • PHP
  • GoLang
  • SQL
  • R Language
  • Android Tutorial
  • Tutorials Archive
  • DSA
  • Data Structures
  • Algorithms
  • DSA for Beginners
  • Basic DSA Problems
  • DSA Roadmap
  • Top 100 DSA Interview Problems
  • DSA Roadmap by Sandeep Jain
  • All Cheat Sheets
  • Data Science & ML
  • Data Science With Python
  • Data Science For Beginner
  • Machine Learning
  • ML Maths
  • Data Visualisation
  • Pandas
  • NumPy
  • NLP
  • Deep Learning
  • Web Technologies
  • HTML
  • CSS
  • JavaScript
  • TypeScript
  • ReactJS
  • NextJS
  • Bootstrap
  • Web Design
  • Python Tutorial
  • Python Programming Examples
  • Python Projects
  • Python Tkinter
  • Python Web Scraping
  • OpenCV Tutorial
  • Python Interview Question
  • Django
  • Computer Science
  • Operating Systems
  • Computer Network
  • Database Management System
  • Software Engineering
  • Digital Logic Design
  • Engineering Maths
  • Software Development
  • Software Testing
  • DevOps
  • Git
  • Linux
  • AWS
  • Docker
  • Kubernetes
  • Azure
  • GCP
  • DevOps Roadmap
  • System Design
  • High Level Design
  • Low Level Design
  • UML Diagrams
  • Interview Guide
  • Design Patterns
  • OOAD
  • System Design Bootcamp
  • Interview Questions
  • Inteview Preparation
  • Competitive Programming
  • Top DS or Algo for CP
  • Company-Wise Recruitment Process
  • Company-Wise Preparation
  • Aptitude Preparation
  • Puzzles
  • School Subjects
  • Mathematics
  • Physics
  • Chemistry
  • Biology
  • Social Science
  • English Grammar
  • Commerce
  • World GK
  • GeeksforGeeks Videos
  • DSA
  • Python
  • Java
  • C++
  • Web Development
  • Data Science
  • CS Subjects
@GeeksforGeeks, Sanchhaya Education Private Limited, All rights reserved
We use cookies to ensure you have the best browsing experience on our website. By using our site, you acknowledge that you have read and understood our Cookie Policy & Privacy Policy
Lightbox
Improvement
Suggest Changes
Help us improve. Share your suggestions to enhance the article. Contribute your expertise and make a difference in the GeeksforGeeks portal.
geeksforgeeks-suggest-icon
Create Improvement
Enhance the article with your expertise. Contribute to the GeeksforGeeks community and help create better learning resources for all.
geeksforgeeks-improvement-icon
Suggest Changes
min 4 words, max Words Limit:1000

Thank You!

Your suggestions are valuable to us.

What kind of Experience do you want to share?

Interview Experiences
Admission Experiences
Career Journeys
Work Experiences
Campus Experiences
Competitive Exam Experiences