-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathToDoApp.jsx
40 lines (35 loc) · 1.34 KB
/
ToDoApp.jsx
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
import { useReducer } from "react";
//import { InputTextArea, InputShow } from './InputTextArea';
const ToDoApp = () => {
// const initialTodo = () => {
// const initialValue = JSON.parse(localStorage.getItem('toDos'));
// if (initialValue) return initialValue;
// return [];
// }
// const reducer = (state, action) => {
// switch (action.type) {
// case 'add-todo':
// return [...state, { text: action.text, toggle: false }];
// case 'delete':
// return state.filter((state, index) => index !== action.id);
// case 'toggle':
// return state.map((state, index) => {
// return (index === action.id) ? { ...state, toggle: !state.toggle } : state;
// })
// case 'edit':
// return state.map((state, index) => {
// return index === action.id ? action.data : state;
// })
// }
// }
// const [state, dispatch] = useReducer(reducer, initialTodo());
// console.log(state);
// localStorage.setItem('toDos', JSON.stringify(state));
// return (
// <>
// <InputTextArea funct={dispatch} />
// <InputShow data={state} dispatch={dispatch} />
// </>
// )
}
export default ToDoApp;