fix: change type of next function
This commit is contained in:
parent
d4cd576586
commit
161fc9a87f
|
@ -1 +1 @@
|
||||||
import{jsx}from"react/jsx-runtime";import{useLocation,Switch,Route,Redirect}from"react-router-dom";var __assign=function(){return(__assign=Object.assign||function(t){for(var r,e=1,o=arguments.length;e<o;e++)for(var n in r=arguments[e])Object.prototype.hasOwnProperty.call(r,n)&&(t[n]=r[n]);return t}).apply(this,arguments)},RouterView=function(t){var r=t.routes,e=t.onEnter,t=useLocation().pathname,o="",n=!0;return e(t,function(t){n=!0,t&&(o=t)}),jsx(Switch,{children:r.map(function(r,t){return r.auth?n?o?jsx(Redirect,{to:o},t):jsx(Route,{path:r.path,render:function(t){return jsx(r.component,__assign({},t,{routes:r.routes}),void 0)}},t):void 0:jsx(Route,{path:r.path,render:function(t){return jsx(r.component,__assign({},t,{routes:r.routes}),void 0)}},t)})},void 0)};export{RouterView};
|
import{jsx}from"react/jsx-runtime";import{useLocation,Switch,Route,Redirect}from"react-router-dom";var __assign=function(){return(__assign=Object.assign||function(t){for(var r,e=1,o=arguments.length;e<o;e++)for(var n in r=arguments[e])Object.prototype.hasOwnProperty.call(r,n)&&(t[n]=r[n]);return t}).apply(this,arguments)},RouterView=function(t){var r=t.routes,e=t.onEnter,t=useLocation().pathname,o="",n=!0;return e(t,function(t){n=!0,t&&(o=t)}),jsx(Switch,{children:r.map(function(r,t){if(n)return o?jsx(Redirect,{to:o},t):jsx(Route,{path:r.path,exact:r.exact,render:function(t){return jsx(r.component,__assign({},t,{routes:r.routes}),void 0)}},t)})},void 0)};export{RouterView};
|
||||||
|
|
|
@ -4,14 +4,19 @@ import { FunctionComponent } from 'react';
|
||||||
interface routeType {
|
interface routeType {
|
||||||
path: string;
|
path: string;
|
||||||
component: React.ComponentType<any>;
|
component: React.ComponentType<any>;
|
||||||
auth?: boolean;
|
|
||||||
exact?: boolean;
|
exact?: boolean;
|
||||||
routes?: Array<routeType> | undefined;
|
routes?: Array<routeType> | undefined;
|
||||||
}
|
}
|
||||||
|
|
||||||
interface RouterViewProps {
|
interface RouterViewProps {
|
||||||
routes: Array<routeType>;
|
routes: Array<routeType>;
|
||||||
onEnter: (to: string, next: Function) => void;
|
/**
|
||||||
|
* Require a function to call before routing.
|
||||||
|
* @param to Pathname of user's destination.
|
||||||
|
* @param next Function to allow rendering.
|
||||||
|
* @usage Read more at [github](https://github.com/syy11cn/config-router/blob/main/README.md).
|
||||||
|
*/
|
||||||
|
onEnter: (to: string, next: (path?: string) => void) => void;
|
||||||
}
|
}
|
||||||
declare const RouterView: FunctionComponent<RouterViewProps>;
|
declare const RouterView: FunctionComponent<RouterViewProps>;
|
||||||
|
|
||||||
|
|
|
@ -10,7 +10,7 @@ interface RouterViewProps {
|
||||||
* @param next Function to allow rendering.
|
* @param next Function to allow rendering.
|
||||||
* @usage Read more at [github](https://github.com/syy11cn/config-router/blob/main/README.md).
|
* @usage Read more at [github](https://github.com/syy11cn/config-router/blob/main/README.md).
|
||||||
*/
|
*/
|
||||||
onEnter: (to: string, next: Function) => void;
|
onEnter: (to: string, next: (path?: string) => void) => void;
|
||||||
}
|
}
|
||||||
|
|
||||||
const RouterView: FunctionComponent<RouterViewProps> = ({
|
const RouterView: FunctionComponent<RouterViewProps> = ({
|
||||||
|
|
Loading…
Reference in New Issue