Skip to content
This repository was archived by the owner on Aug 16, 2024. It is now read-only.

Commit 2cfbf26

Browse files
committed
fix: setting value becomes undefined during the first time use
1 parent 3fe54c9 commit 2cfbf26

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

src/pages/Options/Options.tsx

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -52,10 +52,10 @@ const Options: React.FC = () => {
5252
}
5353

5454
useEffect(() => {
55-
cc(chrome.storage.sync, 'get').then((config: Config) => {
56-
setTargetLang(config.targetLang)
57-
setToken(config.token)
58-
setRegion(config.region)
55+
cc(chrome.storage.sync, 'get').then((config: Partial<Config>) => {
56+
if (config.targetLang !== undefined) setTargetLang(config.targetLang)
57+
if (config.token !== undefined) setToken(config.token)
58+
if (config.region !== undefined) setRegion(config.region)
5959
})
6060
}, [])
6161

0 commit comments

Comments
 (0)