diff options
author | Nick Winans <[email protected]> | 2021-02-16 14:34:09 -0600 |
---|---|---|
committer | Pete Johanson <[email protected]> | 2021-03-11 16:31:34 -0500 |
commit | 4ef11ac4aa5185994db19ef3f69a8c54c70fb06c (patch) | |
tree | 4053be2ed00fa01f03868ac455d07dc4e1ec1496 /docs/src/utils | |
parent | 0df71100581d040178bd0fe8ec0382d84dc59a40 (diff) | |
download | zmk-4ef11ac4aa5185994db19ef3f69a8c54c70fb06c.tar.gz zmk-4ef11ac4aa5185994db19ef3f69a8c54c70fb06c.zip |
feat(docs): Add power profiler
Diffstat (limited to 'docs/src/utils')
-rw-r--r-- | docs/src/utils/hooks.js | 23 |
1 files changed, 23 insertions, 0 deletions
diff --git a/docs/src/utils/hooks.js b/docs/src/utils/hooks.js new file mode 100644 index 0000000000..b8fb27b84b --- /dev/null +++ b/docs/src/utils/hooks.js @@ -0,0 +1,23 @@ +/* + * Copyright (c) 2021 The ZMK Contributors + * + * SPDX-License-Identifier: MIT + */ + +import { useState } from "react"; + +export const useInput = (initialValue) => { + const [value, setValue] = useState(initialValue); + + return { + value, + setValue, + bind: { + value, + onChange: (event) => { + const target = event.target; + setValue(target.type === "checkbox" ? target.checked : target.value); + }, + }, + }; +}; |