react-router-dom
Version:
Declarative routing for React web applications
3 lines (2 loc) • 1.89 kB
JavaScript
import{Router as e,useHref as t,useNavigate as r,useLocation as n,useResolvedLocation as a,useMatch as o,useBlocker as u}from"react-router";import{createBrowserHistory as l,createHashHistory as c}from"history";import"prop-types";import i from"react";export{MemoryRouter,Navigate,Outlet,Redirect,Route,Router,Routes,createRoutesFromChildren,generatePath,matchRoutes,resolveLocation,useBlocker,useHref,useLocation,useMatch,useNavigate,useOutlet,useParams,useResolvedLocation,useRoutes}from"react-router";let s=i.forwardRef((function({as:e="a",onClick:o,replace:u=!1,state:l,target:c,to:s,...m},f){let h=t(s),d=r(),p=n(),w=a(s);return i.createElement(e,Object.assign({},m,{href:h,onClick:function(e){o&&o(e),e.defaultPrevented||0!==e.button||c&&"_self"!==c||e.metaKey||e.altKey||e.ctrlKey||e.shiftKey||(e.preventDefault(),e=w.pathname===p.pathname&&w.search===p.search&&w.hash===p.hash,d(s,{replace:!!u||e,state:l}))},ref:f,target:c}))})),m=i.forwardRef((function({"aria-current":e="page",activeClassName:t="active",activeStyle:r=null,className:n="",style:a=null,to:u,...l},c){let m=o(u);return e=m?e:void 0,t=[n,m?t:null].filter(Boolean).join(" "),i.createElement(s,Object.assign({},l,{"aria-current":e,className:t,ref:c,style:{...a,...m?r:null},to:u}))}));function f(e,t){let r=i.useCallback(t=>{window.confirm(e)&&t.retry()},[e]);u(r,t)}function h({children:t,timeout:r,window:n}){let a=i.useRef(null);return null==a.current&&(a.current=l({window:n})),i.createElement(e,{children:t,history:a.current,timeout:r})}function d({children:t,timeout:r,window:n}){let a=i.useRef(null);return null==a.current&&(a.current=c({window:n})),i.createElement(e,{children:t,history:a.current,timeout:r})}function p({message:e,when:t}){return f(e,t),null}export{h as BrowserRouter,d as HashRouter,s as Link,m as NavLink,p as Prompt,f as usePrompt};
//# sourceMappingURL=react-router-dom.production.min.js.map