Skip to content

Commit

Permalink
[SvgIcon] Add displayName in react-devtools (#21134)
Browse files Browse the repository at this point in the history
  • Loading branch information
gndplayground authored May 25, 2020
1 parent 90babbd commit af413c4
Showing 1 changed file with 7 additions and 7 deletions.
14 changes: 7 additions & 7 deletions packages/material-ui/src/utils/createSvgIcon.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,19 +5,19 @@ 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) => (
<SvgIcon data-mui-test={`${displayName}Icon`} ref={ref} {...props}>
{path}
</SvgIcon>
)),
const Component = (props, ref) => (
<SvgIcon data-mui-test={`${displayName}Icon`} ref={ref} {...props}>
{path}
</SvgIcon>
);

if (process.env.NODE_ENV !== 'production') {
// Need to set `displayName` on the inner component for React.memo.
// React prior to 16.14 ignores `displayName` on the wrapper.
Component.displayName = `${displayName}Icon`;
}

Component.muiName = SvgIcon.muiName;

return Component;
return React.memo(React.forwardRef(Component));
}

0 comments on commit af413c4

Please sign in to comment.