diff options
author | Shin'ya Ueoka <ueokande@i-beam.org> | 2021-04-05 23:05:23 +0900 |
---|---|---|
committer | Shin'ya Ueoka <ueokande@i-beam.org> | 2021-04-06 21:47:04 +0900 |
commit | 21f863d76fbb5ed752ad529f8fbe33e75460027e (patch) | |
tree | 9e90a22ec44fbbf33c14bddfd6d7ea22e464581b /src/console/colorscheme/hooks.ts | |
parent | 9041bae89f54efce14239768e642f99d1f0b35d1 (diff) |
Replace colorscheme state with React Hooks
Diffstat (limited to 'src/console/colorscheme/hooks.ts')
-rw-r--r-- | src/console/colorscheme/hooks.ts | 15 |
1 files changed, 15 insertions, 0 deletions
diff --git a/src/console/colorscheme/hooks.ts b/src/console/colorscheme/hooks.ts new file mode 100644 index 0000000..c9de754 --- /dev/null +++ b/src/console/colorscheme/hooks.ts @@ -0,0 +1,15 @@ +import React from "react"; +import { ColorSchemeUpdateContext } from "./contexts"; +import SettingClient from "../clients/SettingClient"; + +export const useColorSchemeRefresh = () => { + const update = React.useContext(ColorSchemeUpdateContext); + const settingClient = new SettingClient(); + const refresh = React.useCallback(() => { + settingClient.getColorScheme().then((newScheme) => { + update(newScheme); + }); + }, []); + + return refresh; +}; |