当我点击提交按钮时,我需要重定向到这个页面 pageOne,所以我用谷歌搜索并找到了一个react-router并使用了这一行this.props.history.push("/anotherPage");
,但它没有重定向。它抛出一个错误 Invariant failed: You should not use <Route> outside a <Router>
Can you tell me how to fix it. 在下面提供我的代码片段和沙箱。
https://codesandbox.io/s/material-demo-n9o7s
<!-- language-all: lang-or-tag-here -->
anotherPage = () => {
console.log("redictToStepper --->");
this.props.history.push("/anotherPage");
};
render() {
const { classes } = this.props;
const { checkBoxvalues } = this.state;
return (
<div className={classes.root}>increase when I hit submit button</div>
);
}
export default withRouter(withStyles(styles)(RadioButtonsGroup));