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