Skip to content

Instantly share code, notes, and snippets.

@lenkan
lenkan / use-location.js
Created March 2, 2019 18:26
React hook that keeps up to date with the current location.
// @ts-check
import { useState, useEffect } from 'react'
function getCurrentLocation () {
return {
pathname: window.location.pathname,
search: window.location.search
}
}