I have a React form which has the following form submission button:
<Link
className="btn btn-secondary btn-width-200 search-submit"
to={{pathname: '/booking/search', query: this.state.filters}}>
Search
</Link>
In the above link
I want to call a function handleSubmit(evt)
on button click.
handleSubmit(evt) {
evt.preventDefault();
this.setState({form_submitted: true});
}
<Link className="btn btn-secondary btn-width-200 search-submit" to={{pathname: '/booking/search', query: this.state.filters}} onClick={this.handleSubmit.bind(this)}>Search</Link>
But the following ignores the to={{pathname: '/booking/search', query: this.state.filters}}
and just takes handleSubmit
function into consideration
Is there anyway to add to={{pathname: '/booking/search', query: this.state.filters}}
to the handleSubmit
function? Or is there anyway to resolve this issue?
I have a React form which has the following form submission button:
<Link
className="btn btn-secondary btn-width-200 search-submit"
to={{pathname: '/booking/search', query: this.state.filters}}>
Search
</Link>
In the above link
I want to call a function handleSubmit(evt)
on button click.
handleSubmit(evt) {
evt.preventDefault();
this.setState({form_submitted: true});
}
<Link className="btn btn-secondary btn-width-200 search-submit" to={{pathname: '/booking/search', query: this.state.filters}} onClick={this.handleSubmit.bind(this)}>Search</Link>
But the following ignores the to={{pathname: '/booking/search', query: this.state.filters}}
and just takes handleSubmit
function into consideration
Is there anyway to add to={{pathname: '/booking/search', query: this.state.filters}}
to the handleSubmit
function? Or is there anyway to resolve this issue?
3 Answers
Reset to default 2This