Skip to content

Commit

Permalink
[zero] Always replace the createUseThemeProps call (mui#40885)
Browse files Browse the repository at this point in the history
  • Loading branch information
siriwatknp authored and mostafa-rio committed Feb 3, 2024
1 parent c51ed31 commit 9250870
Showing 1 changed file with 5 additions and 9 deletions.
14 changes: 5 additions & 9 deletions packages/zero-runtime/src/processors/createUseThemeProps.ts
Original file line number Diff line number Diff line change
Expand Up @@ -44,21 +44,17 @@ export class CreateUseThemePropsProcessor extends BaseProcessor {
const t = this.astService;

const { themeArgs: { theme } = {} } = this.options as IOptions;
if (!theme?.components?.[this.componentName]?.defaultProps) {
return;
}

const useThemePropsImportIdentifier = t.addNamedImport(
this.tagSource.imported,
process.env.PACKAGE_NAME as string,
);

this.replacer(
t.callExpression(useThemePropsImportIdentifier, [
valueToLiteral(theme.components[this.componentName].defaultProps),
]),
true,
);
let replacement: Expression = t.stringLiteral(this.componentName);
if (theme?.components?.[this.componentName]?.defaultProps) {
replacement = valueToLiteral(theme.components[this.componentName].defaultProps);
}
this.replacer(t.callExpression(useThemePropsImportIdentifier, [replacement]), true);
}

public override get asSelector(): string {
Expand Down

0 comments on commit 9250870

Please sign in to comment.