UNPKG

@guruhotel/aura-hooks

Version:

🪝 Hooks library designed by the Guruhotel team for Aura UI

1 lines 330 B
import{useState as e}from"react";export function getInputOnChange(e){return t=>{if(t)if("function"==typeof t)e(t);else if("object"==typeof t&&"nativeEvent"in t){const{currentTarget:n}=t;"checkbox"===n.type?e(n.checked):e(n.value)}else e(t);else e(t)}}export function useInputState(t){const[n,o]=e(t);return[n,getInputOnChange(o)]}