Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Lesson 1 4 #17

Open
wants to merge 23 commits into
base: main
Choose a base branch
from
Open
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
made changes to check and learn
OmarAlareeki committed Sep 4, 2021
commit 0b9614bca15d9dff3d55169cc3859e6508ba4538
21 changes: 11 additions & 10 deletions src/AddTodoForm.js
Original file line number Diff line number Diff line change
@@ -1,25 +1,26 @@
import React from 'react'

const AddTodoForm = (props) => {


const handleAddTodo = (event) => {

event.preventDefault();
let todoTitle = event.target.title.value;
console.log(todoTitle);
console.log(event);
props.onAddTodo(todoTitle);
let titleTodo = event.target.title.value;
props.onAddTodo(titleTodo)
event.target.reset();

}

return (
<div>
<form onSubmit={handleAddTodo}>
<label htmlFor="todoTitle" >Title: </label>
<input id="todoTitle" type="text" name="title" />
<button type="submit">Add</button>
</form>
<form onSubmit={handleAddTodo}>
<label htmlFor="todoTitle" >Title: </label>
<input id="todoTitle" type="text" name="title" />
<button type="submit">Add</button>
</form>
</div>
)
}

export default AddTodoForm
export default AddTodoForm
11 changes: 6 additions & 5 deletions src/App.js
Original file line number Diff line number Diff line change
@@ -1,19 +1,20 @@
import React from 'react';
import AddTodoForm from './AddTodoForm';
import TodoList from './TodoList';
import './style.css'
import './style.css';

function App() {

const [newTodo, setNewTodo] = React.useState("")
function App() {

const [newTodo, setNewTodo] = React.useState("");

return (
<div className="container">
<div>
<header>
<h1>Todo List</h1>
</header>
<AddTodoForm onAddTodo={setNewTodo}/>
<p>{newTodo}</p>
<p>{newTodo}</p>
<TodoList />
</div>
);