I’m quite new to React and Hooks and trying to make contact form with hooks. I can't change my values in the field and can't type anything in the input and the onChange() is not firing. But there is no error on browser and console, so I can not figure it out. Do you know the reason?
Here is my code.
import React , {useState} from 'react';
import Button from '@material-ui/core/Button';
import Dialog from '@material-ui/core/Dialog';
import DialogActions from '@material-ui/core/DialogActions';
import DialogContent from '@material-ui/core/DialogContent';
import DialogTitle from '@material-ui/core/DialogTitle';
import TextInput from './TextInput'
const FormDialog = props => {
const {
handleClose,
open,
} = props;
const [values, setValues] = useState({
name: "",
email: "",
description: ""
});
const handleChange = event => {
setValues({
...values,
[event.target.name]: event.target.value
});
};
return(
<Dialog
open={open}
onClose={handleClose}
aria-labelledby="alert-dialog-title"
aria-describedby="alert-dialog-description"
>
<DialogTitle id="alert-dialog-title">Contact Form</DialogTitle>
<DialogContent>
<TextInput
label={“name} multiline={false} rows={1}
value={values.name} type={"text"} onChange={handleChange}
/>
<TextInput
label={“email”} multiline={false} rows={1}
value={values.email} type={"email"} onChange={handleChange}
/>
<TextInput
label={“more”} multiline={false} rows={5}
value={values.description} type={"text"} onChange={handleChange}
/>
</DialogContent>
<DialogActions>
<Button onClick={props.handleClose} color="primary">
cancel
</Button>
<Button onClick={submitForm} color="primary" autoFocus>
send
</Button>
</DialogActions>
</Dialog>
)
}
export default FormDialog