forked from kofal.net/zmk
feat(docs): Add power profiler
This commit is contained in:
committed by
Pete Johanson
parent
0df7110058
commit
4ef11ac4aa
23
docs/src/utils/hooks.js
Normal file
23
docs/src/utils/hooks.js
Normal file
@@ -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);
|
||||
},
|
||||
},
|
||||
};
|
||||
};
|
||||
Reference in New Issue
Block a user