diff --git a/src/Inputs/Input.tsx b/src/Inputs/Input.tsx index 83989f3..be6e563 100644 --- a/src/Inputs/Input.tsx +++ b/src/Inputs/Input.tsx @@ -8,11 +8,20 @@ interface InputProps extends React.InputHTMLAttributes { } const Input = React.forwardRef(( - { name, component = 'input', model, ...props }, + { name, component = 'input', model, onChange, ...props }, ref, ) => { const { inputName, inputId, value, setValue } = useInertiaInput({ name, model }) + const handleChange = (e: React.ChangeEvent) => { + if(onChange) { + onChange(e) + return + } + + setValue(e.target.value) + } + const Element = component return ( @@ -20,7 +29,7 @@ const Input = React.forwardRef(( name={ inputName } id={ inputId } value={ value } - onChange={ (e: React.ChangeEvent) => setValue(e.target.value) } + onChange={ handleChange } ref={ ref } { ...props } />