1.0.2 • Published 1 year ago

virtual-history-v5 v1.0.2

Weekly downloads
-
License
MIT
Repository
github
Last release
1 year ago

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()
parametersdescription
historieslist of history
clearHistoryindex optionaltarget indexdefault: 0clear history listclose all history
restartWithlocationlocator of react routerlike history.push(location)clear all historyand replace first order with specific
moveTokeykey of locationexample: kv67oichange the current location to targetif target stay before current it uses go(-...)if target stay after current it uses go(...)
1.0.2

1 year ago

1.0.1

1 year ago

1.0.0

1 year ago

0.1.0

1 year ago