mirror of
https://github.com/pybricks/pybricks-code.git
synced 2026-09-15 11:04:49 +00:00
settings: convert flashCurrentProgram to react hook
This commit is contained in:
@@ -1,9 +1,12 @@
|
||||
// SPDX-License-Identifier: MIT
|
||||
// Copyright (c) 2022 The Pybricks Authors
|
||||
|
||||
import { useCallback } from 'react';
|
||||
import { Dispatch, SetStateAction, useCallback } from 'react';
|
||||
import { useLocalStorage } from 'usehooks-ts';
|
||||
|
||||
// this is private type from usehooks-ts
|
||||
type SetValue<T> = Dispatch<SetStateAction<T>>;
|
||||
|
||||
/** Hook for "showDocs" setting. */
|
||||
export function useSettingIsShowDocsEnabled(): {
|
||||
isSettingShowDocsEnabled: boolean;
|
||||
@@ -26,3 +29,8 @@ export function useSettingIsShowDocsEnabled(): {
|
||||
toggleIsSettingShowDocsEnabled,
|
||||
};
|
||||
}
|
||||
|
||||
/** Hook for "flashCurrentProgram" setting. */
|
||||
export function useSettingFlashCurrentProgram(): [boolean, SetValue<boolean>] {
|
||||
return useLocalStorage<boolean>('setting.flashCurrentProgram', false);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user