With react-router
I can use the Link
element to create links which are natively handled by react router.
I see internally it calls t
With the current React version (15.3), this.props.history.push('/location');
worked for me, but it showed the following warning:
browser.js:49 Warning: [react-router]
props.history
andcontext.history
are deprecated. Please usecontext.router
.
and I solved it using context.router
like this:
import React from 'react';
class MyComponent extends React.Component {
constructor(props) {
super(props);
this.backPressed = this.backPressed.bind(this);
}
backPressed() {
this.context.router.push('/back-location');
}
...
}
MyComponent.contextTypes = {
router: React.PropTypes.object.isRequired
};
export default MyComponent;