-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path.eslintcache
1 lines (1 loc) · 3.02 KB
/
.eslintcache
1
[{"C:\\Users\\ASUS\\Desktop\\todo-react-app\\src\\index.js":"1","C:\\Users\\ASUS\\Desktop\\todo-react-app\\src\\App.js":"2"},{"size":197,"mtime":1609948594046,"results":"3","hashOfConfig":"4"},{"size":1642,"mtime":1610029082693,"results":"5","hashOfConfig":"4"},{"filePath":"6","messages":"7","errorCount":0,"warningCount":0,"fixableErrorCount":0,"fixableWarningCount":0,"usedDeprecatedRules":"8"},"1i8mt3v",{"filePath":"9","messages":"10","errorCount":0,"warningCount":1,"fixableErrorCount":0,"fixableWarningCount":0,"source":"11"},"C:\\Users\\ASUS\\Desktop\\todo-react-app\\src\\index.js",[],["12","13"],"C:\\Users\\ASUS\\Desktop\\todo-react-app\\src\\App.js",["14"],"import React, { useState, useEffect, useRef } from 'react';\nimport { v4 as uuidv4 } from 'uuid';\nimport './App.css';\n\nfunction App() {\n const firstLoad = useRef(true);\n const [inputValue,setInputValue] = useState('');\n const [allTodos,setAllTodos] = useState([]);\n\n const addTodo = (e) => {\n e.preventDefault();\n if(inputValue.trim() === '')\n return;\n setAllTodos([...allTodos, {\n text: inputValue,\n id: uuidv4(),\n }]);\n\n setInputValue('');\n }\n\n const removeTodo = (id) =>{\n setAllTodos(allTodos.filter((todo) => todo.id !== id));\n };\n\n useEffect(() =>{\n if (firstLoad.current){\n firstLoad.current = false;\n } else {\n localStorage.setItem(\"todoList\", JSON.stringify([...allTodos]));\n }\n },[allTodos]);\n\n useEffect(() => {\n if (localStorage.getItem(\"todoList\") !== null){\n const newTodos = localStorage.getItem(\"todoList\");\n setAllTodos(JSON.parse([...allTodos, newTodos]));\n };\n },[]);\n\n return (\n <div className=\"App\">\n <div className=\"container\">\n <form onSubmit={addTodo}>\n <input autoFocus type=\"text\" placeholder=\"Enter Todo Task...\"\n value={inputValue}\n onChange={(e) => setInputValue(e.target.value) }/>\n <button type=\"submit\">Add Todo</button>\n </form>\n {allTodos.map(todo => (\n <div key={todo.id} className=\"todo\">\n <p>{todo.text}</p>\n <i onClick={()=> removeTodo(todo.id)} className=\"far fa-trash-alt\"></i>\n </div>\n ))}\n </div>\n </div>\n );\n}\n\nexport default App;\n",{"ruleId":"15","replacedBy":"16"},{"ruleId":"17","replacedBy":"18"},{"ruleId":"19","severity":1,"message":"20","line":39,"column":5,"nodeType":"21","endLine":39,"endColumn":7,"suggestions":"22"},"no-native-reassign",["23"],"no-negated-in-lhs",["24"],"react-hooks/exhaustive-deps","React Hook useEffect has a missing dependency: 'allTodos'. Either include it or remove the dependency array. You can also do a functional update 'setAllTodos(a => ...)' if you only need 'allTodos' in the 'setAllTodos' call.","ArrayExpression",["25"],"no-global-assign","no-unsafe-negation",{"desc":"26","fix":"27"},"Update the dependencies array to be: [allTodos]",{"range":"28","text":"29"},[972,974],"[allTodos]"]