Commit 494a4681 authored by ι™ˆεΈ…'s avatar ι™ˆεΈ…

Remove Authorized circular reference

parent 422c7207
import React from 'react';
import PromiseRender from './PromiseRender';
import { CURRENT } from './index';
import { CURRENT } from './renderAuthorize';
function isPromise(obj) {
return (
......
......@@ -44,7 +44,7 @@ export default class PromiseRender extends React.PureComponent {
};
render() {
const Component = this.state.component;
const { component: Component } = this.state;
return Component ? (
<Component {...this.props} />
) : (
......
......@@ -2,31 +2,10 @@ import Authorized from './Authorized';
import AuthorizedRoute from './AuthorizedRoute';
import Secured from './Secured';
import check from './CheckPermissions.js';
/* eslint-disable import/no-mutable-exports */
let CURRENT = 'NULL';
import renderAuthorize from './renderAuthorize';
Authorized.Secured = Secured;
Authorized.AuthorizedRoute = AuthorizedRoute;
Authorized.check = check;
/**
* use authority or getAuthority
* @param {string|()=>String} currentAuthority
*/
const renderAuthorize = currentAuthority => {
if (currentAuthority) {
if (currentAuthority.constructor.name === 'Function') {
CURRENT = currentAuthority();
}
if (currentAuthority.constructor.name === 'String') {
CURRENT = currentAuthority;
}
} else {
CURRENT = 'NULL';
}
return Authorized;
};
export { CURRENT };
export default renderAuthorize;
export default renderAuthorize(Authorized);
/* eslint-disable import/no-mutable-exports */
let CURRENT = 'NULL';
/**
* use authority or getAuthority
* @param {string|()=>String} currentAuthority
*/
const renderAuthorize = Authorized => {
return currentAuthority => {
if (currentAuthority) {
if (currentAuthority.constructor.name === 'Function') {
CURRENT = currentAuthority();
}
if (currentAuthority.constructor.name === 'String') {
CURRENT = currentAuthority;
}
} else {
CURRENT = 'NULL';
}
return Authorized;
};
};
export { CURRENT };
export default Authorized => renderAuthorize(Authorized);
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment