(WrappedComponent: React.ComponentType > {
-
- /**
- * The default properties.
- */
- static defaultProps = {
- spinning: false
- };
-
- /**
- * Create the Loadify.
- *
- * @constructs Loadify
- */
- constructor(props: P & Partial (WrappedComponent: React.ComponentType ) {
-
- /**
- * The wrapper class for the given component.
- *
- * @class The MappifiedComponent
- * @extends React.Component
- */
- return class MappifiedComponent extends React.Component (
- WrappedComponent: React.ComponentType ): React.ComponentType {
-
- /**
- * The wrapper class for the given component.
- *
- * @class The VisibleComponent
- * @extends React.Component
- */
- return class VisibleComponent extends React.Component {
-
- /**
- * Checks if the current component (identified by it's name) should be
- * visible or not.
- *
- * @param componentName The name of the component.
- * @return Whether the component should be visible or not.
- */
- isVisibleComponent = (componentName: string) => {
- const activeModules = this.props.activeModules || [];
-
- return activeModules.some((activeModule: any) => {
- if (!activeModule.name) {
- return false;
- } else {
- return activeModule.name === componentName;
- }
- });
- };
-
- /**
- * The render function.
- */
- render() {
- // Filter out extra props that are specific to this HOC and shouldn't be
- // passed through.
- const {
- activeModules,
- ...passThroughProps
- } = this.props;
-
- // Check if the current component should be visible or not.
- const isVisible = this.isVisibleComponent(this.props.name);
-
- // Inject props into the wrapped component. These are usually state
- // values or instance methods.
- return (
- isVisible ?
-