-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
編集されたコードは localStorage に保存しておくことで実現した. 単にリロードされたときなどには localStorage に保存しておいたやつを読み込む. ヘッダーをクリックすると localStorage に保存しておいたコードを消すことでデフォルトコードに戻せるようにしておいた.
- Loading branch information
r-takaic
committed
Mar 14, 2022
1 parent
1cfe44e
commit fd72d07
Showing
2 changed files
with
54 additions
and
8 deletions.
There are no files selected for viewing
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
const KEY = { | ||
SRC: "src", | ||
TEST: "test", | ||
} as const; | ||
|
||
type Key = typeof KEY[keyof typeof KEY]; | ||
|
||
const getItem = (key: Key) => localStorage.getItem(key); | ||
|
||
const removeItem = (key: Key) => localStorage.removeItem(key); | ||
|
||
const setItem = (key: Key, value: string) => localStorage.setItem(key, value); | ||
|
||
const clear = () => localStorage.clear(); | ||
|
||
export { KEY, getItem, removeItem, setItem, clear }; |