My problem is i create custom hook and link with my form hook tracing input text filed and update in state. I want after click on button submit input value in state with that custom hook and i am stuck here...
export const useForm = (initialValue) => {
const [value, setValue] = useState(initialValue);
return [value, e =>
setValue({
...value, [e.target.name] : e.target.value
})];
}
this is my custom hook
<form onSubmit={updateCityName}>
<div className="form">
<div className="input-field">
<i className="material-icons prefix">location_on</i>
<input id="icon_prefix" type="text" name="cityName" value={value.cityName} onChange={handleChange} className="validate" />
<label htmlFor ="icon_prefix">City Name</label>
</div>
<button className="btn waves-effect waves-light" type="submit" name="action">Submit</button>
</div>
</form>
this is my form and this is function
const updateCityName = e => {
e.preventDefault();
handleChange('what i must here type for update state???');
}