As a novice in React.js, I am facing an issue where setState is not functioning properly when submitting a form. Any suggestions on how to resolve this problem?
> class Home extends Component{ constructor(props){
> super(props)
> this.state = {
> username:'',
> email:'',
> message:''
> } }
>
> handleUsernameChange = (event) => { //event as parameter to capture
> value
> this.setState({
> username: event.target.value
> }) } handleEmailChange = (event) => { //event as parameter to capture value
> this.setState({
> email: event.target.value
> }) } handleMessageChange = (event) => { //event as parameter to capture value
> this.setState({
> message: event.target.value
> }) }
>
> handleSubmit = (event) =>{
> alert('${this.state.username} ${this.state.email} ${this.state.message}')
> event.preventDefault() }