How does the "Add Day" button work without actually telling it to call the submit function when clicked.Here is the form
render (){
return(
<form onSubmit={this.submit}>
<label htmlFor="resort">Resort Name</label>
<input id="resort" type="text" defaultValue={this.props.resort} ref="resort" required/>
<label htmlFor="date">Date</label>
<input id="date" type="date" defaultValue={this.props.date} ref="date" required/>
<div>
<input id="rainy" type="checkbox" defaultChecked={this.props.rainy} ref="rainy" />
<label htmlFor="rainy" class="weather" >Rainy Day</label>
</div>
<div>
<input id="sunny" type="checkbox" defaultChecked={this.props.sunny} ref="sunny" />
<label htmlFor="sunny" class="weather" >Sunny Day</label>
</div>
<button>Add Day</button>
</form>
)
}
and here is the submit function
submit(e){
e.preventDefault();
this.refs.resort.value='';
this.refs.date.value='';
this.refs.rainy.value=false;
this.refs.sunny.value=false;
}
Please i need a good explanation on how the button still calls the submit function just like that.