質問するログイン新規登録

質問編集履歴

1

コードの抜粋を掲載

2021/04/20 07:10

投稿

ryota002
ryota002

スコア20

title CHANGED
File without changes
body CHANGED
@@ -20,6 +20,27 @@
20
20
  }
21
21
  ```
22
22
 
23
+ > App.jsxの抜粋
24
+ ```js
25
+ function App() {
26
+ const [todos, setTodos] = useState(
27
+ JSON.parse(localStorage.getItem("todos")) || []
28
+ );
29
+ const [inputText, setInputText] = useState("");
30
+ const [editingText, setEditingText] = useState("");
31
+ const [filterState, setFilterState] = useState(FILTER_STATE.ALL);
32
+
33
+ useEffect(() => {
34
+ localStorage.setItem("todos", JSON.stringify(todos));
35
+ });
36
+
37
+ // 1文字ずつしか入力できなくなった。2021/04/16
38
+ function updateInputText(e) {
39
+ setInputText(e.target.value);
40
+ }
41
+
42
+ ```
43
+
23
44
  ### 発生している問題・エラーメッセージ
24
45
 
25
46
  react-router を使う前はうまく行っていたのですが、routerを使うとうまくいかなくなりました。