react-browser-pathname
A window location wrapper for reading the current pathname.
Installation
Using npm:
$ npm install --save react-browser-pathname
Usage
Towards the top of your app, add the BrowserPathname
Provider.
; const AppProviders = <BrowserPathname> <App /> </BrowserPathname>;
Within your any ancestor component use the hooks, e.g.:
; const MyComponent = { const pathname = ; const pushPath = ; const replacePath = ; return <div> <pre> pathname </pre> <button onClick= >Push path to navigate</button> <button onClick= >Replace path to navigate</button> </div> ;};