A class helps to trigger callback functions by history traversal
npm install --save bf-lifecycleimportBackForwardLifecyclefrom'bf-lifecycle';letdata;constbfLifecycle=newBackForwardLifecycle({callback: ()=>{data='bfcache';},storeState: ()=>{sessionStorage.setItem('data','nobfcache');},restoreState: ()=>sessionStorage.getItem('data'),options: {hasDependency: true,withClearScrollWillNotStoreBfCache: true,},});bfLifecycle.mount();data=bfLifecycle.triggerRestoreState();See here
<ahref="ansrlm.github.io/bf-lifecycle">BF-LIFECYCLE</a>Soon be added time-expire function on bf-lifecycle v1.1.0
Then bf-lifecycle will support react framework as hook (expect in v2.1.0)
MIT © ansrlm

