0.0.13 ā€¢ Published 7 months ago

@tenqube/location-history v0.0.13

Weekly downloads
-
License
MIT
Repository
github
Last release
7 months ago

ā— development halted.

@tenqube/locaiton-history

This is a React Hook that can save and use location information in an array format according to history changes.

'@tenqube/locaiton-history' detects changes in the DOM and saves the location history, so it must be used with a routing-related library such as 'react-router-dom'.

Installation

$ npm install @tenqube/locaiton-history

Quick Start

For sample configuration, we used 'react-router-dom'.

import React, { useEffect } from 'react'
import { createRoot } from 'react-dom/client'
import { createBrowserRouter, RouterProvider, Link } from 'react-router-dom'
import LocaitonHistoryProvider, { useLocationHistory, ILocationHistory } from '@tenqube/locaiton-history'

const White = () => { const history: ILocationHistory = useLocationHistory()

useEffect(() => { console.log(history) }, history)

return (

<div>
  <h1>white</h1>
  <Link to="/black?foo=bar">/black?foo=bar</Link>
</div>

) }

const Black = () => { const history: ILocationHistory = useLocationHistory()

useEffect(() => { console.log(history) }, history)

return (

<div>
  <h1>black</h1>
  <Link to="/">/</Link>
</div>

) }

const router = createBrowserRouter( { path: "/", element: }, { path: "/black", element: } )

createRoot(document.getElementById("root") as HTMLElement).render( )

## Interfaces
```ts
interface ILocationHistory {
  list: ILocationVO[],
  before: ILocationVO | null
}
interface ILocationVO {
  readonly hash: string
  readonly host: string
  readonly hostname: string
  readonly href: string
  readonly origin: string
  readonly pathname: string
  readonly port: string
  readonly protocol: string
  readonly search: string
  
  readonly searchObj: unknown
  readonly hashObj: unknown
}

Demo

demo

0.0.13

7 months ago

0.0.12

7 months ago

0.0.11

7 months ago

0.0.10

7 months ago

0.0.9

7 months ago

0.0.8

7 months ago

0.0.7

7 months ago

0.0.6

7 months ago

0.0.5

7 months ago

0.0.4

7 months ago

0.0.3

7 months ago

0.0.2

7 months ago