use-history

1.4.1 • Public • Published

use-history

the history api as a react hook

usage

import useHistory, {Link} from 'use-history'
 
const App = () => {
    const {url} = useHistory()
 
    return <>
        url is {url}
        <Link href='/hello'>go to /hello</Link>
    </>
}

it listens to popstate events while the component is mounted and rerenders when the url changes. Link is a boneless wrapper around <a> to update the url directly.

licence

ISC. © Bren Brightwell

Readme

Keywords

none

Package Sidebar

Install

npm i use-history

Weekly Downloads

497

Version

1.4.1

License

ISC

Unpacked Size

2.38 kB

Total Files

3

Last publish

Collaborators

  • quarterto