diff --git a/src/App.js b/src/App.js index 3017066..0a76811 100644 --- a/src/App.js +++ b/src/App.js @@ -1,19 +1,40 @@ -import React from "react"; -import Greet from "./Greet"; -const App = () => { +import React, { useState } from "react"; +import "./App.css"; + +function App() { + const [tasks, setTasks] = useState([]); + const [input, setInput] = useState(""); + + const addTask = () => { + setTasks([...tasks, input]); + setInput(""); + }; + + const deleteTask = (index) => { + tasks.splice(index, 1); + setTasks([...tasks]); + }; + return (
- -

This is a para

-
- - - - - - +
    + {tasks.map((task, index) => ( +
  • + {task} + +
  • + ))} +
+ setInput(e.target.value)} + /> + + +

No of tasks to be done : {tasks.length}

); -}; +} export default App; diff --git a/src/Greet.js b/src/Greet.js deleted file mode 100644 index bf19bd8..0000000 --- a/src/Greet.js +++ /dev/null @@ -1,16 +0,0 @@ -import React from "react"; -import "./App.css"; - -const Greet = (props) => { - const { name, age, gender } = props; - console.log(props); - return ( - <> -

Hello {name}

-

My age is {age}

-

My gender is {gender}

- {props.children} - - ); -}; -export default Greet;