Skip to content
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

[core] Remove createSvgIcon duplication #20308

Merged
Merged
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
21 changes: 1 addition & 20 deletions packages/material-ui-icons/src/utils/createSvgIcon.js
Original file line number Diff line number Diff line change
@@ -1,20 +1 @@
import React from 'react';
import SvgIcon from '@material-ui/core/SvgIcon';

export default function createSvgIcon(path, displayName) {
const Component = React.memo(
React.forwardRef((props, ref) => (
<SvgIcon data-mui-test={`${displayName}Icon`} ref={ref} {...props}>
{path}
</SvgIcon>
)),
);

if (process.env.NODE_ENV !== 'production') {
Component.displayName = `${displayName}Icon`;
}

Component.muiName = SvgIcon.muiName;

return Component;
}
export { createSvgIcon as default } from '@material-ui/core/utils';
2 changes: 1 addition & 1 deletion packages/material-ui-lab/src/internal/svg-icons/Add.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import * as React from 'react';
import createSvgIcon from './createSvgIcon';
import { createSvgIcon } from '@material-ui/core/utils';

/**
* @ignore - internal component.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import * as React from 'react';
import createSvgIcon from './createSvgIcon';
import { createSvgIcon } from '@material-ui/core/utils';

/**
* @ignore - internal component.
Expand Down
2 changes: 1 addition & 1 deletion packages/material-ui-lab/src/internal/svg-icons/Close.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import * as React from 'react';
import createSvgIcon from './createSvgIcon';
import { createSvgIcon } from '@material-ui/core/utils';

/**
* @ignore - internal component.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import * as React from 'react';
import createSvgIcon from './createSvgIcon';
import { createSvgIcon } from '@material-ui/core/utils';

/**
* @ignore - internal component.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import * as React from 'react';
import createSvgIcon from './createSvgIcon';
import { createSvgIcon } from '@material-ui/core/utils';

/**
* @ignore - internal component.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import * as React from 'react';
import createSvgIcon from './createSvgIcon';
import { createSvgIcon } from '@material-ui/core/utils';

/**
* @ignore - internal component.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import * as React from 'react';
import createSvgIcon from './createSvgIcon';
import { createSvgIcon } from '@material-ui/core/utils';

/**
* @ignore - internal component.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import * as React from 'react';
import createSvgIcon from './createSvgIcon';
import { createSvgIcon } from '@material-ui/core/utils';

/**
* @ignore - internal component.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import * as React from 'react';
import createSvgIcon from './createSvgIcon';
import { createSvgIcon } from '@material-ui/core/utils';

/**
* @ignore - internal component.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import * as React from 'react';
import createSvgIcon from './createSvgIcon';
import { createSvgIcon } from '@material-ui/core/utils';

/**
* @ignore - internal component.
Expand Down
2 changes: 1 addition & 1 deletion packages/material-ui-lab/src/internal/svg-icons/Star.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import * as React from 'react';
import createSvgIcon from './createSvgIcon';
import { createSvgIcon } from '@material-ui/core/utils';

/**
* @ignore - internal component.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import * as React from 'react';
import createSvgIcon from './createSvgIcon';
import { createSvgIcon } from '@material-ui/core/utils';

/**
* @ignore - internal component.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import * as React from 'react';
import createSvgIcon from './createSvgIcon';
import createSvgIcon from '../../utils/createSvgIcon';

/**
* @ignore - internal component.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import * as React from 'react';
import createSvgIcon from './createSvgIcon';
import createSvgIcon from '../../utils/createSvgIcon';

/**
* @ignore - internal component.
Expand Down
2 changes: 1 addition & 1 deletion packages/material-ui/src/internal/svg-icons/Cancel.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import * as React from 'react';
import createSvgIcon from './createSvgIcon';
import createSvgIcon from '../../utils/createSvgIcon';

/**
* @ignore - internal component.
Expand Down
2 changes: 1 addition & 1 deletion packages/material-ui/src/internal/svg-icons/CheckBox.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import * as React from 'react';
import createSvgIcon from './createSvgIcon';
import createSvgIcon from '../../utils/createSvgIcon';

/**
* @ignore - internal component.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import * as React from 'react';
import createSvgIcon from './createSvgIcon';
import createSvgIcon from '../../utils/createSvgIcon';

/**
* @ignore - internal component.
Expand Down
2 changes: 1 addition & 1 deletion packages/material-ui/src/internal/svg-icons/CheckCircle.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import * as React from 'react';
import createSvgIcon from './createSvgIcon';
import createSvgIcon from '../../utils/createSvgIcon';

/**
* @ignore - internal component.
Expand Down
2 changes: 1 addition & 1 deletion packages/material-ui/src/internal/svg-icons/Close.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import * as React from 'react';
import createSvgIcon from './createSvgIcon';
import createSvgIcon from '../../utils/createSvgIcon';

/**
* @ignore - internal component.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import * as React from 'react';
import createSvgIcon from './createSvgIcon';
import createSvgIcon from '../../utils/createSvgIcon';

/**
* @ignore - internal component.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import * as React from 'react';
import createSvgIcon from './createSvgIcon';
import createSvgIcon from '../../utils/createSvgIcon';

/**
* @ignore - internal component.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import * as React from 'react';
import createSvgIcon from './createSvgIcon';
import createSvgIcon from '../../utils/createSvgIcon';

/**
* @ignore - internal component.
Expand Down
2 changes: 1 addition & 1 deletion packages/material-ui/src/internal/svg-icons/MoreHoriz.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import * as React from 'react';
import createSvgIcon from './createSvgIcon';
import createSvgIcon from '../../utils/createSvgIcon';

/**
* @ignore - internal component.
Expand Down
2 changes: 1 addition & 1 deletion packages/material-ui/src/internal/svg-icons/Person.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import * as React from 'react';
import createSvgIcon from './createSvgIcon';
import createSvgIcon from '../../utils/createSvgIcon';

/**
* @ignore - internal component.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import * as React from 'react';
import createSvgIcon from './createSvgIcon';
import createSvgIcon from '../../utils/createSvgIcon';

/**
* @ignore - internal component.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import * as React from 'react';
import createSvgIcon from './createSvgIcon';
import createSvgIcon from '../../utils/createSvgIcon';

/**
* @ignore - internal component.
Expand Down
2 changes: 1 addition & 1 deletion packages/material-ui/src/internal/svg-icons/Warning.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import * as React from 'react';
import createSvgIcon from './createSvgIcon';
import createSvgIcon from '../../utils/createSvgIcon';

/**
* @ignore - internal component.
Expand Down
20 changes: 0 additions & 20 deletions packages/material-ui/src/internal/svg-icons/createSvgIcon.js

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
import * as React from 'react';
import SvgIcon from '@material-ui/core/SvgIcon';
import React from 'react';
import SvgIcon from '../SvgIcon';

/**
* Private module reserved for @material-ui/x packages.
*/
export default function createSvgIcon(path, displayName) {
const Component = React.memo(
React.forwardRef((props, ref) => (
Expand Down
3 changes: 2 additions & 1 deletion packages/material-ui/src/utils/index.js
Original file line number Diff line number Diff line change
@@ -1,12 +1,13 @@
export { default as capitalize } from './capitalize';
export { default as deprecatedPropType } from './deprecatedPropType';
export { default as isMuiElement } from './isMuiElement';
export { default as createSvgIcon } from './createSvgIcon';
export { default as ownerDocument } from './ownerDocument';
export { default as ownerWindow } from './ownerWindow';
export { default as requirePropFactory } from './requirePropFactory';
export { default as setRef } from './setRef';
export { default as unsupportedProp } from './unsupportedProp';
export { default as useControlled } from './useControlled';
export { default as useEventCallback } from './useEventCallback';
export { default as useForkRef } from './useForkRef';
export { default as useControlled } from './useControlled';
export { useIsFocusVisible } from './focusVisible';