Pablo Darde
Pablo Darde

Reputation: 6402

Navigating with React router without using links

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

Upvotes: 1

Views: 500

Answers (1)

ctrlplusb
ctrlplusb

Reputation: 13127

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

Upvotes: 4

Related Questions