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 1 commit
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
7 changes: 2 additions & 5 deletions packages/material-ui-icons/src/utils/createSvgIcon.d.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,2 @@
import SvgIcon from '@material-ui/core/SvgIcon';

declare function createSvgIcon(path: React.ReactNode, displayName: string): typeof SvgIcon;

export default createSvgIcon;
export { default } from '@material-ui/core/createSvgIcon';
export * from '@material-ui/core/createSvgIcon';
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 { default } from '@material-ui/core/createSvgIcon';
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/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 '@material-ui/core/createSvgIcon';

/**
* @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/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 '@material-ui/core/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 '@material-ui/core/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 '@material-ui/core/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 '@material-ui/core/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 '@material-ui/core/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 '@material-ui/core/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 '@material-ui/core/createSvgIcon';

/**
* @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/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 '@material-ui/core/createSvgIcon';

/**
* @ignore - internal component.
Expand Down
5 changes: 5 additions & 0 deletions packages/material-ui/src/createSvgIcon/createSvgIcon.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
import SvgIcon from '@material-ui/core/SvgIcon';

declare function createSvgIcon(path: React.ReactNode, displayName: string): typeof SvgIcon;

export default createSvgIcon;
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
2 changes: 2 additions & 0 deletions packages/material-ui/src/createSvgIcon/index.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
export { default } from './createSvgIcon';
export * from './createSvgIcon';
1 change: 1 addition & 0 deletions packages/material-ui/src/createSvgIcon/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export { default } from './createSvgIcon';
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 '../../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 '../../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 '../../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 '../../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 '../../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 '../../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 '../../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 '../../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 '../../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 '../../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 '../../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 '../../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 '../../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 '../../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 '../../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.