Skip to content

Commit

Permalink
fix: cascading context for custom libraries and components
Browse files Browse the repository at this point in the history
  • Loading branch information
yawetse committed May 11, 2021
1 parent 530e39f commit 1de4d8c
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions src/components.ts
Original file line number Diff line number Diff line change
Expand Up @@ -812,6 +812,11 @@ export function getCustomComponentsCacheKey(customComponents:defs.jsonxCustomCom
export function getReactLibrariesAndComponents(this: defs.Context, customComponents: defs.jsonxCustomComponent[]): defs.jsonxLibrariesAndComponents {
const customComponentsCacheKey = getCustomComponentsCacheKey(customComponents);
if(generatedCustomComponents.has(customComponentsCacheKey)) return generatedCustomComponents.get(customComponentsCacheKey);
const cxt = {
componentLibraries:{},
reactComponents:{},
...this,
};

const customComponentLibraries: defs.jsonxComponentLibraries = {};
const customReactComponents: defs.jsonxComponent = {};
Expand Down Expand Up @@ -846,19 +851,22 @@ export function getReactLibrariesAndComponents(this: defs.Context, customCompone
{}
);
} else customComponentLibraries[name] = window[name];
cxt.componentLibraries[name] = customComponentLibraries[name];
} else if (type === "component") {
if (jsonx) {
customReactComponents[name] = getReactClassComponent.call(this,
jsonx,
options
) as defs.genericComponent;
} else customReactComponents[name] = window[name];
cxt.reactComponents[name] = customReactComponents[name];
} else if (type === "function" ) {
if (functionComponent || functionBody) {
customReactComponents[
name
] = getCustomFunctionComponent.call(this, { options, functionBody, functionComponent, jsonxComponent:jsonx, });
} else customReactComponents[name] = window[name];
cxt.reactComponents[name] = customReactComponents[name];
}
});
}
Expand Down

0 comments on commit 1de4d8c

Please sign in to comment.