在React非组件的地方使用路由

661 阅读1分钟

进入有个需求,需要登录成功后跳转到首页,当然判断的逻辑逻辑放到actionCreators里面

此时需要通过以下几步实现在actionCreators里实现路由跳转

三行代码

import { createBrowserHistory } from 'history';
const history = createBrowserHistory();
history.push('/');