From 4ef11ac4aa5185994db19ef3f69a8c54c70fb06c Mon Sep 17 00:00:00 2001 From: Nick Winans Date: Tue, 16 Feb 2021 14:34:09 -0600 Subject: feat(docs): Add power profiler --- docs/src/utils/hooks.js | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) create mode 100644 docs/src/utils/hooks.js (limited to 'docs/src/utils/hooks.js') diff --git a/docs/src/utils/hooks.js b/docs/src/utils/hooks.js new file mode 100644 index 0000000..b8fb27b --- /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); + }, + }, + }; +}; -- cgit v1.2.3