Skip to content

Commit

Permalink
[core] Remove createSvgIcon duplication (#20308)
Browse files Browse the repository at this point in the history
  • Loading branch information
oliviertassinari committed Mar 29, 2020
1 parent 9573e82 commit 8ea2df8
Show file tree
Hide file tree
Showing 32 changed files with 35 additions and 70 deletions.
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';

0 comments on commit 8ea2df8

Please sign in to comment.