blob: b8fb27b84b3260b8210d3b9686c33786bf83434d (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
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);
},
},
};
};
|