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 1104990 commit 85c8c03
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,9 @@ export const resolveEncodedCodeRefs = (
const executableCodeRef: CodeRef = async () =>
loadReferencedObject(ref, entryModule, pluginID, errorCallback);

e.properties[propName] = applyCodeRefSymbol(executableCodeRef);
const loader = applyCodeRefSymbol(executableCodeRef);
Object.defineProperty(loader, 'name', { value: ref.$codeRef });
e.properties[propName] = loader;
});

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 85c8c03

Please sign in to comment.