我正在尝试在用户登录后重定向到主页。问题是URL更改了,但页面没有更改。 我已经创建了自定义历史记录,并将其导入到action.js文件中。我不知道为什么它不起作用。你能帮我吗?
history.js文件
import { createBrowserHistory } from 'history';
export default createBrowserHistory();
action.js文件
import history from 'history.js';
export const goToHomePage = () => (dispatch) => {
console.log('redirect to admin panel');
history.push('/admin-panel');
};
如果您想查看我的router.js文件
const Routes = () => {
return (
<BrowserRouter>
<Switch>
<AppPath exact path="/" component={SignIn} layout={Layout} />
<AppPath path="/admin-panel" component={Main} layout={Layout} />
</Switch>
</BrowserRouter>
);
};