Skip to content

Commit

Permalink
Fixes bug in SceneHierarchy when downstream doesn't correctly load SV…
Browse files Browse the repository at this point in the history
…G files (#47)

Co-authored-by: Mitchell Lee <[email protected]>
  • Loading branch information
TheEvilDev and Mitchell Lee authored Aug 9, 2022
1 parent dedcf8e commit 62a1c69
Showing 1 changed file with 7 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -26,20 +26,22 @@ const SceneNodeLabel: FC<SceneNodeLabelProps> = ({
}, [visible, onVisibilityChange]);

const componentTypeIcons = componentTypes
?.filter((type) => Object.keys(KnownComponentType).includes(type))
?.filter((type) => !!type && Object.keys(KnownComponentType).includes(type))
.map(
/* istanbul ignore next */ (type) => {
try {
// eslint-disable-next-line @typescript-eslint/no-var-requires
const { ReactComponent: Icon } = require(`../../../../../assets/icons/${type.toLowerCase()}.svg`);
const {
ReactComponent: Icon,
// eslint-disable-next-line @typescript-eslint/no-var-requires
} = require(`@svgr/webpack!../../../../../assets/icons/${type.toLowerCase()}.svg`); // We specify the loader here, because we don't want calling webpack config to override this behavior by accident.
return <Icon key={type} data-testid={`scene-node-type-${type}`} className='tm-icon-component-type' />;
} catch (e) {
// if we're missing an icon, or there's just some issue, swallow it, because it's really not that important.
log?.error(`Failed to load "${type}" icon appears to be missing`, e);
return null;
return <React.Fragment />;
}
},
);
) || <React.Fragment />;

return (
<span className={'tm-scene-node-label'}>
Expand Down

0 comments on commit 62a1c69

Please sign in to comment.