Skip to content

Commit

Permalink
Add name to coderef function.
Browse files Browse the repository at this point in the history
Async component compares functions by name too.
  • Loading branch information
rawagner committed Aug 10, 2021
1 parent 7ebe4ee commit d567846
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -93,9 +93,10 @@ export const resolveEncodedCodeRefs = (
): Extension[] =>
_.cloneDeep(extensions).map((e) => {
deepForOwn<EncodedCodeRef>(e.properties, isEncodedCodeRef, (ref, key, obj) => {
obj[key] = applyCodeRefSymbol(async () =>
const loader = applyCodeRefSymbol(async () =>
loadReferencedObject(ref, entryModule, pluginID, errorCallback),
);
obj[key] = Object.defineProperty(loader, 'name', { value: `${pluginID}-${ref.$codeRef}` });
});

return e;
Expand Down
2 changes: 1 addition & 1 deletion frontend/public/components/utils/async.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import { LoadingBox } from './status-box';
*/
const sameLoader = (a: () => Promise<React.ComponentType>) => (
b: () => Promise<React.ComponentType>,
) => (a || 'a').toString() === (b || 'b').toString();
) => a?.name === b?.name && (a || 'a').toString() === (b || 'b').toString();

enum AsyncComponentError {
ComponentNotFound = 'COMPONENT_NOT_FOUND',
Expand Down

0 comments on commit d567846

Please sign in to comment.