I'm using react-router to build a simple application. I can't use browserHistory approach, so, I'm using the hashHistory approach. However, I'm stucked in a point. How can I do a function 'clickHandler' for a submit form, in order to land on another route?
Here is a snippet:
onSubmit: function() {
//go to some route here...
},
render: function() {
return(
<button onClick={this.onSubmit} >Submit</button>
)
}
thanks
答案 0 :(得分:4)
Can you try the following:
import { hashHistory } from 'react-router';
onSubmit: function() {
hashHistory.push('/foo');
},
You can see the full history
API here:
https://github.com/ReactJSTraining/history