CJY0208 / react-router-cache-route

Route with cache for react-router V5 like <keep-alive /> in Vue
https://www.npmjs.com/package/react-router-cache-route
MIT License
1.16k stars 113 forks source link

Vite下报错 #102

Closed pincman closed 3 years ago

pincman commented 3 years ago

代码

import { BasicLayout } from './layouts';
import Dashboard from './pages/dashboard/welcome';

const App = () => (
    <Router>
        <CacheSwitch>
            <CacheRoute exact path="/" component={BasicLayout} />
            <Route exact path="/p" component={Dashboard} />
            <Route render={() => <div>404 Not Found</div>} />
        </CacheSwitch>
    </Router>
);

export default App;

报错index.js:176 Uncaught ReferenceError: useHistory is not defined

CJY0208 commented 3 years ago

react-router-dom 的版本是多少?

pincman commented 3 years ago

@CJY0208 5.2.0

CJY0208 commented 3 years ago

需要先检查一下业务代码中是否有未定义的 useHistory 方法,检查了代码,不像是 cache-route 内部的问题

可以尝试提供在线或者 github demo 来便于分析

CJY0208 commented 3 years ago

无反馈,暂时关闭