1.0.2 • Published 1 year ago
virtual-history-v5 v1.0.2
virtual-history-v5
Installation
Npm
npm install virtual-history-v5
Yarn
yarn add virtual-history-v5
SET UP
import VirtualHistoryProvider
under BrowserRouter
import { VirtualHistoryProvider } from "virtual-history-v5"
ReactDOM.createRoot(document.getElementById('root') as HTMLElement).render(
<BrowserRouter>
<VirtualHistoryProvider>
<Switch>
...
</Switch>
</VirtualHistoryProvider>
</BrowserRouter>,
)
HOW TO USE
import { useVirtualHistory } from "virtual-history-v5"
const { histories, clearHistory, restartWith, moveTo } = useVirtualHistory()
parameters | description | |
---|---|---|
histories | list of history | |
clearHistory | index optionaltarget indexdefault: 0 | clear history listclose all history |
restartWith | locationlocator of react routerlike history.push(location) | clear all historyand replace first order with specific |
moveTo | keykey of locationexample: kv67oi | change the current location to targetif target stay before current it uses go(-...)if target stay after current it uses go(...) |