Skip to content

Instantly share code, notes, and snippets.

@borfirbora
Created May 18, 2025 17:29
Show Gist options
  • Save borfirbora/dd2961421a6c1919f2ae4aeb286a8130 to your computer and use it in GitHub Desktop.
Save borfirbora/dd2961421a6c1919f2ae4aeb286a8130 to your computer and use it in GitHub Desktop.
örnek dosyam
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}
/>&nbsp;<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