Skip to content

[core] refactor: remove manual displayName #46147

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions babel.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,10 @@ module.exports = function getBabelConfig(api) {
: []),
];

if (process.env.NODE_ENV !== 'test') {
plugins.push('@mui/internal-babel-plugin-display-name');
}

if (process.env.NODE_ENV === 'test') {
plugins.push([
'babel-plugin-module-resolver',
Expand Down
4 changes: 0 additions & 4 deletions docs/src/components/pricing/LicenseModelContext.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,6 @@ import * as React from 'react';

const LicenseModel = React.createContext<any>({});

if (process.env.NODE_ENV !== 'production') {
LicenseModel.displayName = 'LicenseModel';
}

export function LicenseModelProvider(props: any) {
const [licenseModel, setLicenseModel] = React.useState<string>('annual');
const value = React.useMemo(
Expand Down
4 changes: 0 additions & 4 deletions docs/src/modules/components/PageContext.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,4 @@ export interface MuiPageContext {

const PageContext = React.createContext<MuiPageContext>(undefined!);

if (process.env.NODE_ENV !== 'production') {
PageContext.displayName = 'PageContext';
}

export default PageContext;
8 changes: 0 additions & 8 deletions docs/src/modules/components/ThemeContext.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -87,16 +87,8 @@ export const DispatchContext = React.createContext<React.ActionDispatch<any>>(()
throw new Error('Forgot to wrap component in `ThemeProvider`');
});

if (process.env.NODE_ENV !== 'production') {
DispatchContext.displayName = 'ThemeDispatchContext';
}

export const ThemeOptionsContext = React.createContext(themeInitialOptions);

if (process.env.NODE_ENV !== 'production') {
ThemeOptionsContext.displayName = 'ThemeOptionsContext';
}

export function ThemeProvider(props: React.PropsWithChildren) {
const { children } = props;

Expand Down
3 changes: 0 additions & 3 deletions docs/src/modules/utils/codeStylingSolution.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,6 @@ const CodeStylingContext = React.createContext({
codeStyling: CODE_STYLING.SYSTEM,
setCodeStyling: () => {},
});
if (process.env.NODE_ENV !== 'production') {
CodeStylingContext.displayName = 'CodeStyling';
}

function useFirstRender() {
const firstRenderRef = React.useRef(true);
Expand Down
3 changes: 0 additions & 3 deletions docs/src/modules/utils/codeVariant.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,6 @@ const CodeVariantContext = React.createContext({
codeVariant: CODE_VARIANTS.TS,
setCodeVariant: () => {},
});
if (process.env.NODE_ENV !== 'production') {
CodeVariantContext.displayName = 'CodeVariant';
}

function useFirstRender() {
const firstRenderRef = React.useRef(true);
Expand Down
4 changes: 0 additions & 4 deletions docs/src/pages/versions/VersionsContext.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,4 @@ import * as React from 'react';
*/
const VersionsContext = React.createContext(null);

if (process.env.NODE_ENV !== 'production') {
VersionsContext.displayName = 'VersionsContext';
}

export default VersionsContext;
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -122,6 +122,7 @@
"@babel/register": "^7.27.1",
"@mui-internal/api-docs-builder": "workspace:^",
"@mui-internal/api-docs-builder-core": "workspace:^",
"@mui/internal-babel-plugin-display-name": "^1.0.0",
"@mui/internal-babel-plugin-resolve-imports": "^2.0.3",
"@mui/internal-babel-plugin-minify-errors": "^2.0.4",
"@mui/internal-docs-utils": "workspace:^",
Expand Down
3 changes: 0 additions & 3 deletions packages/mui-docs/src/i18n/i18n.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -51,9 +51,6 @@ const UserLanguageContext = React.createContext<UserLanguageContextValue>({
userLanguage: '',
setUserLanguage: () => {},
});
if (process.env.NODE_ENV !== 'production') {
UserLanguageContext.displayName = 'UserLanguage';
}

export interface UserLanguageProviderProps {
children: React.ReactNode;
Expand Down
4 changes: 0 additions & 4 deletions packages/mui-joy/src/Accordion/AccordionContext.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,4 @@ const AccordionContext = React.createContext<
}>
>({});

if (process.env.NODE_ENV !== 'production') {
AccordionContext.displayName = 'AccordionContext';
}

export default AccordionContext;
4 changes: 0 additions & 4 deletions packages/mui-joy/src/AvatarGroup/AvatarGroup.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,6 @@ import useSlot from '../utils/useSlot';

export const AvatarGroupContext = React.createContext<AvatarGroupOwnerState | undefined>(undefined);

if (process.env.NODE_ENV !== 'production') {
AvatarGroupContext.displayName = 'AvatarGroupContext';
}

const useUtilityClasses = () => {
const slots = {
root: ['root'],
Expand Down
4 changes: 0 additions & 4 deletions packages/mui-joy/src/ButtonGroup/ButtonGroupContext.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,4 @@ interface IButtonGroupContext {
*/
const ButtonGroupContext = React.createContext<IButtonGroupContext>({});

if (process.env.NODE_ENV !== 'production') {
ButtonGroupContext.displayName = 'ButtonGroupContext';
}

export default ButtonGroupContext;
4 changes: 0 additions & 4 deletions packages/mui-joy/src/Chip/ChipContext.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,4 @@ const ChipColorContext = React.createContext<Pick<ChipProps, 'disabled' | 'varia
color: undefined,
});

if (process.env.NODE_ENV !== 'production') {
ChipColorContext.displayName = 'ChipColorContext';
}

export default ChipColorContext;
4 changes: 0 additions & 4 deletions packages/mui-joy/src/FormControl/FormControlContext.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,4 @@ export type FormControlContextValue =

const FormControlContext = React.createContext<FormControlContextValue>(undefined);

if (process.env.NODE_ENV !== 'production') {
FormControlContext.displayName = 'FormControlContext';
}

export default FormControlContext;
4 changes: 0 additions & 4 deletions packages/mui-joy/src/List/ComponentListContext.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,4 @@ import * as React from 'react';

const ComponentListContext = React.createContext<string | undefined>(undefined);

if (process.env.NODE_ENV !== 'production') {
ComponentListContext.displayName = 'ComponentListContext';
}

export default ComponentListContext;
4 changes: 0 additions & 4 deletions packages/mui-joy/src/List/GroupListContext.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,4 @@ import * as React from 'react';

const GroupListContext = React.createContext<undefined | 'menu' | 'select'>(undefined);

if (process.env.NODE_ENV !== 'production') {
GroupListContext.displayName = 'GroupListContext';
}

export default GroupListContext;
4 changes: 0 additions & 4 deletions packages/mui-joy/src/List/NestedListContext.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,4 @@ import * as React from 'react';

const NestedListContext = React.createContext<boolean | string>(false);

if (process.env.NODE_ENV !== 'production') {
NestedListContext.displayName = 'NestedListContext';
}

export default NestedListContext;
4 changes: 0 additions & 4 deletions packages/mui-joy/src/List/RowListContext.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,4 @@ import * as React from 'react';

const RowListContext = React.createContext(false);

if (process.env.NODE_ENV !== 'production') {
RowListContext.displayName = 'RowListContext';
}

export default RowListContext;
4 changes: 0 additions & 4 deletions packages/mui-joy/src/List/WrapListContext.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,4 @@ import * as React from 'react';

const WrapListContext = React.createContext(false);

if (process.env.NODE_ENV !== 'production') {
WrapListContext.displayName = 'WrapListContext';
}

export default WrapListContext;
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,4 @@ const ListItemButtonOrientationContext = React.createContext<'horizontal' | 'ver
'horizontal',
);

if (process.env.NODE_ENV !== 'production') {
ListItemButtonOrientationContext.displayName = 'ListItemButtonOrientationContext';
}

export default ListItemButtonOrientationContext;
4 changes: 0 additions & 4 deletions packages/mui-joy/src/ListSubheader/ListSubheaderContext.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,4 @@ const ListSubheaderContext = React.createContext<
undefined | React.Dispatch<React.SetStateAction<string>>
>(undefined);

if (process.env.NODE_ENV !== 'production') {
ListSubheaderContext.displayName = 'ListSubheaderContext';
}

export default ListSubheaderContext;
4 changes: 0 additions & 4 deletions packages/mui-joy/src/Modal/CloseModalContext.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,4 @@ import { ModalProps } from './ModalProps';

const CloseModalContext = React.createContext<undefined | ModalProps['onClose']>(undefined);

if (process.env.NODE_ENV !== 'production') {
CloseModalContext.displayName = 'CloseModalContext';
}

export default CloseModalContext;
4 changes: 0 additions & 4 deletions packages/mui-joy/src/ModalDialog/ModalDialogSizeContext.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,4 @@ import { ModalDialogProps } from './ModalDialogProps';

const ModalDialogSizeContext = React.createContext<undefined | ModalDialogProps['size']>(undefined);

if (process.env.NODE_ENV !== 'production') {
ModalDialogSizeContext.displayName = 'ModalDialogSizeContext';
}

export default ModalDialogSizeContext;
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,4 @@ const ModalDialogVariantColorContext = React.createContext<
| (Pick<ModalDialogProps, 'variant' | 'color'> & { labelledBy?: string; describedBy?: string })
>(undefined);

if (process.env.NODE_ENV !== 'production') {
ModalDialogVariantColorContext.displayName = 'ModalDialogVariantColorContext';
}

export default ModalDialogVariantColorContext;
4 changes: 0 additions & 4 deletions packages/mui-joy/src/RadioGroup/RadioGroupContext.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,4 @@ const RadioGroupContext = React.createContext<
})
>(undefined);

if (process.env.NODE_ENV !== 'production') {
RadioGroupContext.displayName = 'RadioGroupContext';
}

export default RadioGroupContext;
4 changes: 0 additions & 4 deletions packages/mui-joy/src/Tabs/SizeTabsContext.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,4 @@ import { TabsProps } from './TabsProps';

const SizeTabsContext = React.createContext<Exclude<TabsProps['size'], undefined>>('md');

if (process.env.NODE_ENV !== 'production') {
SizeTabsContext.displayName = 'SizeTabsContext';
}

export default SizeTabsContext;
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,4 @@ const ToggleButtonGroupContext = React.createContext<ToggleButtonGroupContextTyp
undefined,
);

if (process.env.NODE_ENV !== 'production') {
ToggleButtonGroupContext.displayName = 'ToggleButtonGroupContext';
}

export default ToggleButtonGroupContext;
8 changes: 0 additions & 8 deletions packages/mui-joy/src/Typography/Typography.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,6 @@ import { TypographySystem } from '../styles/types';
*/
export const TypographyNestedContext = React.createContext(false);

if (process.env.NODE_ENV !== 'production') {
TypographyNestedContext.displayName = 'TypographyNestedContext';
}

/**
* @internal
* Typography's level will be inherit within this context unless an explicit `level` prop is provided.
Expand All @@ -32,10 +28,6 @@ if (process.env.NODE_ENV !== 'production') {
*/
export const TypographyInheritContext = React.createContext(false);

if (process.env.NODE_ENV !== 'production') {
TypographyInheritContext.displayName = 'TypographyInheritContext';
}

const useUtilityClasses = (ownerState: TypographyOwnerState) => {
const { gutterBottom, noWrap, level, color, variant } = ownerState;

Expand Down
4 changes: 0 additions & 4 deletions packages/mui-joy/src/styles/variantColorInheritance.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,6 @@ import { ColorPaletteProp, VariantProp } from '@mui/joy/styles/types';

const VariantColorContext = React.createContext<string | undefined>(undefined);

if (process.env.NODE_ENV !== 'production') {
VariantColorContext.displayName = 'VariantColorContext';
}

/**
* @internal For internal usage only.
*
Expand Down
3 changes: 0 additions & 3 deletions packages/mui-lab/src/TabContext/TabContext.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,6 @@ import PropTypes from 'prop-types';
* @type {React.Context<{ idPrefix: string; value: string } | null>}
*/
const Context = React.createContext(null);
if (process.env.NODE_ENV !== 'production') {
Context.displayName = 'TabContext';
}

function useUniquePrefix() {
const [id, setId] = React.useState(null);
Expand Down
4 changes: 0 additions & 4 deletions packages/mui-lab/src/Timeline/TimelineContext.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,4 @@ import * as React from 'react';
*/
const TimelineContext = React.createContext({});

if (process.env.NODE_ENV !== 'production') {
TimelineContext.displayName = 'TimelineContext';
}

export default TimelineContext;
4 changes: 0 additions & 4 deletions packages/mui-material/src/Accordion/AccordionContext.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,4 @@ import * as React from 'react';
*/
const AccordionContext = React.createContext({});

if (process.env.NODE_ENV !== 'production') {
AccordionContext.displayName = 'AccordionContext';
}

export default AccordionContext;
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,4 @@ const ButtonGroupButtonContext = React.createContext<ButtonPositionClassName | u
undefined,
);

if (process.env.NODE_ENV !== 'production') {
ButtonGroupButtonContext.displayName = 'ButtonGroupButtonContext';
}

export default ButtonGroupButtonContext;
4 changes: 0 additions & 4 deletions packages/mui-material/src/ButtonGroup/ButtonGroupContext.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,4 @@ interface ButtonGroupContextType {
*/
const ButtonGroupContext = React.createContext<ButtonGroupContextType>({});

if (process.env.NODE_ENV !== 'production') {
ButtonGroupContext.displayName = 'ButtonGroupContext';
}

export default ButtonGroupContext;
4 changes: 0 additions & 4 deletions packages/mui-material/src/Dialog/DialogContext.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,4 @@ interface DialogContextValue {

const DialogContext = React.createContext<DialogContextValue>({});

if (process.env.NODE_ENV !== 'production') {
DialogContext.displayName = 'DialogContext';
}

export default DialogContext;
4 changes: 0 additions & 4 deletions packages/mui-material/src/FormControl/FormControlContext.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,4 @@ export interface FormControlState extends Pick<FormControlProps, ContextFromProp
*/
const FormControlContext = React.createContext<FormControlState | undefined>(undefined);

if (process.env.NODE_ENV !== 'production') {
FormControlContext.displayName = 'FormControlContext';
}

export default FormControlContext;
4 changes: 0 additions & 4 deletions packages/mui-material/src/GridLegacy/GridLegacyContext.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,4 @@ import * as React from 'react';
*/
const GridLegacyContext = React.createContext();

if (process.env.NODE_ENV !== 'production') {
GridLegacyContext.displayName = 'GridLegacyContext';
}

export default GridLegacyContext;
4 changes: 0 additions & 4 deletions packages/mui-material/src/ImageList/ImageListContext.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,4 @@ import * as React from 'react';
*/
const ImageListContext = React.createContext({});

if (process.env.NODE_ENV !== 'production') {
ImageListContext.displayName = 'ImageListContext';
}

export default ImageListContext;
4 changes: 0 additions & 4 deletions packages/mui-material/src/List/ListContext.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,4 @@ import * as React from 'react';
*/
const ListContext = React.createContext({});

if (process.env.NODE_ENV !== 'production') {
ListContext.displayName = 'ListContext';
}

export default ListContext;
4 changes: 0 additions & 4 deletions packages/mui-material/src/RadioGroup/RadioGroupContext.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,4 @@ export interface RadioGroupContextValue {
*/
const RadioGroupContext = React.createContext<RadioGroupContextValue | undefined>(undefined);

if (process.env.NODE_ENV !== 'production') {
RadioGroupContext.displayName = 'RadioGroupContext';
}

export default RadioGroupContext;
Loading