react-hook-effect
Version:
> Is a react-library consist of some react hooks > Hooks are for two areas: 1) for UI 2) for Web API
1 lines • 607 B
JavaScript
import{useEffect,useState,useCallback}from"react";const useLocation=()=>{const[a,o]=useState(null);var e,t,n,l,s,c,[r,i,u]=[useCallback(a=>window.location.replace(a),[]),useCallback(a=>window.location.assign(a),[]),useCallback(a=>window.location.reload(a),[])];return useEffect(()=>{o(window.location)},[window.location.pathname,window.location.search,window.location.hash]),a?({protocol:e,hostname:t,port:n,pathname:l,search:s,hash:c}=a,{urlSegments:{protocol:e,hostname:t,port:n,pathname:l,search:s,hash:c},replace:r,assign:i,reload:u}):{urlSegments:null,replace:r,assign:i,reload:u}};export{useLocation};