Created
May 18, 2025 17:29
-
-
Save borfirbora/dd2961421a6c1919f2ae4aeb286a8130 to your computer and use it in GitHub Desktop.
örnek dosyam
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import { useEffect, useState } from 'react'; | |
import TodoList from './components/TodoList' | |
import { useDispatch, useSelector } from 'react-redux'; | |
import { addTodo } from './redux/todosSlice' | |
import Form from './components/SubmitForm'; | |
function App() { | |
const title = "Yapılacak Listesi"; | |
const dispatch = useDispatch(); | |
const todos = useSelector(state => state.todos.items) | |
const [todo, setTodo] = useState(''); | |
const handleKey = (e) => { | |
if (e.key === 'Enter') { | |
dispatch(addTodo({ | |
id: Math.random().toString(), | |
text: todo, | |
completed: false | |
})); | |
setTodo(''); | |
} | |
} | |
useEffect(() => { | |
document.title = title; | |
}, []) | |
return ( | |
<> | |
<h1>{title}</h1> | |
<input | |
type='text' | |
placeholder='Notunuzu buraya yazın.' | |
onChange={(e) => setTodo(e.target.value)} | |
value={todo} | |
accessKey='n' | |
onKeyDown={handleKey} | |
/> <input | |
type="button" | |
value='Ekle' | |
onClick={() => { | |
dispatch(addTodo({ | |
id: Math.random().toString(), | |
text: todo, | |
completed: false | |
})); | |
setTodo(''); | |
}} | |
disabled={!todo} | |
accessKey='e' | |
/> | |
<br /> | |
<TodoList /> | |
<hr /> | |
<Form /> | |
</> | |
) | |
} | |
export default App; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment