Skip to content

Commit 129daff

Browse files
oliviertassinarieps1lon
authored andcommitted
[core] Replace hoistMuiStatics usages (#14722)
The whole community is using hoist-non-react-statics, let's go for it. We should be able to remove the yarn version lock at some point. *This change is taken from #14560 as an effort not to merge too big pull requests.*
1 parent 50a445d commit 129daff

File tree

9 files changed

+15
-31
lines changed

9 files changed

+15
-31
lines changed

packages/material-ui-icons/builder.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -168,7 +168,7 @@ async function main(options) {
168168

169169
let renameFilter = options.renameFilter;
170170
if (typeof renameFilter === 'string') {
171-
/* eslint-disable-next-line global-require, import/no-dynamic-require */
171+
// eslint-disable-next-line global-require, import/no-dynamic-require
172172
renameFilter = require(renameFilter).default;
173173
}
174174
if (typeof renameFilter !== 'function') {

packages/material-ui-styles/src/withStyles.js

+3-2
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
11
import React from 'react';
22
import PropTypes from 'prop-types';
33
import warning from 'warning';
4-
import { getDisplayName, hoistMuiStatics } from '@material-ui/utils';
4+
import hoistNonReactStatics from 'hoist-non-react-statics';
5+
import { getDisplayName } from '@material-ui/utils';
56
import makeStyles from './makeStyles';
67
import RefHolder from './RefHolder';
78
import getThemeProps from './getThemeProps';
@@ -88,7 +89,7 @@ const withStyles = (stylesOrCreator, options = {}) => Component => {
8889
WithStyles.displayName = `WithStyles(${getDisplayName(Component)})`;
8990
}
9091

91-
hoistMuiStatics(WithStyles, Component);
92+
hoistNonReactStatics(WithStyles, Component);
9293

9394
return WithStyles;
9495
};

packages/material-ui-styles/src/withStyles.test.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -22,11 +22,11 @@ describe('withStyles', () => {
2222
mount.cleanUp();
2323
});
2424

25-
it('does not hoist statics', () => {
25+
it('hoist statics', () => {
2626
const Test = () => null;
2727
Test.someStatic = 'will not get hoisted';
2828
const TestWithStyles = withStyles({})(Test);
29-
assert.strictEqual(TestWithStyles.someStatic, undefined);
29+
assert.strictEqual(TestWithStyles.someStatic, Test.someStatic);
3030
});
3131

3232
it('hoists mui internals', () => {

packages/material-ui-styles/src/withTheme.js

+3-2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import React from 'react';
22
import PropTypes from 'prop-types';
3-
import { getDisplayName, hoistMuiStatics } from '@material-ui/utils';
3+
import hoistNonReactStatics from 'hoist-non-react-statics';
4+
import { getDisplayName } from '@material-ui/utils';
45
import useTheme from './useTheme';
56
import RefHolder from './RefHolder';
67

@@ -38,7 +39,7 @@ const withTheme = Component => {
3839
WithTheme.displayName = `WithTheme(${getDisplayName(Component)})`;
3940
}
4041

41-
hoistMuiStatics(WithTheme, Component);
42+
hoistNonReactStatics(WithTheme, Component);
4243

4344
return WithTheme;
4445
};

packages/material-ui-styles/src/withTheme.test.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -37,11 +37,11 @@ describe('withTheme', () => {
3737
assert.strictEqual(wrapper.text(), 'foo');
3838
});
3939

40-
it('does not hoist statics', () => {
40+
it('hoist statics', () => {
4141
const Test = () => null;
4242
Test.someStatic = 'will not get hoisted';
4343
const TestWithTheme = withTheme(Test);
44-
assert.strictEqual(TestWithTheme.someStatic, undefined);
44+
assert.strictEqual(TestWithTheme.someStatic, Test.someStatic);
4545
});
4646

4747
it('hoists mui internals', () => {

packages/material-ui-utils/src/hoistMuiStatics.js

-18
This file was deleted.
-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
export { default as chainPropTypes } from './chainPropTypes';
22
export { default as exactProp } from './exactProp';
33
export { default as getDisplayName } from './getDisplayName';
4-
export { default as hoistMuiStatics } from './hoistMuiStatics';
54
export { default as ponyfillGlobal } from './ponyfillGlobal';

packages/material-ui/src/InputBase/InputBase.test.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -239,7 +239,7 @@ describe('<InputBase />', () => {
239239

240240
beforeEach(() => {
241241
// we need a class for enzyme otherwise: "Can't call ::setState on functional component"
242-
/* eslint-disable-next-line react/prefer-stateless-function */
242+
// eslint-disable-next-line react/prefer-stateless-function
243243
class Provider extends React.Component {
244244
render() {
245245
const { context, ...other } = this.props;

packages/material-ui/src/utils/withForwardedRef.js

+3-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import React from 'react';
2-
import { getDisplayName, hoistMuiStatics } from '@material-ui/utils';
2+
import hoistNonReactStatics from 'hoist-non-react-statics';
3+
import { getDisplayName } from '@material-ui/utils';
34

45
/**
56
* Enables ref forwarding on a given component that uses `innerRef` to forward refs
@@ -28,5 +29,5 @@ export default function withForwardedRef(Component) {
2829
ForwardRefComponent.displayName = `ForwardRef(${getDisplayName(Component)})`;
2930
}
3031

31-
return hoistMuiStatics(ForwardRefComponent, Component);
32+
return hoistNonReactStatics(ForwardRefComponent, Component);
3233
}

0 commit comments

Comments
 (0)