react-router-cache-route
react-router-cache-route copied to clipboard
微信公众号网页 返回位置错误
import React from 'react';
import { HashRouter, useHistory } from 'react-router-dom';
import { CacheRoute, CacheSwitch } from 'react-router-cache-route';
function List() {
const history = useHistory();
return (
<div>
{Array.from(Array(100).keys()).map((item) => (
<div key={item} onClick={() => history.push('/a')}>{item}</div>
))}
</div>
);
}
function App() {
return (
<HashRouter>
<CacheSwitch>
<CacheRoute path="/" exact component={List} saveScrollPosition/>
<CacheRoute path="/a" exact>asdfasdf</CacheRoute>
</CacheSwitch>
</HashRouter>
);
}
export default App;