Skip to content

Commit 1765c7b

Browse files
authored
[Grid2] Add compatible props warning (#43801)
1 parent ce9a6e6 commit 1765c7b

File tree

1 file changed

+15
-0
lines changed

1 file changed

+15
-0
lines changed

packages/mui-material/src/Grid2/Grid2.tsx

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ import PropTypes from 'prop-types';
33
import { createGrid as createGrid2 } from '@mui/system/Grid';
44
import { SxProps, SystemProps } from '@mui/system';
55
import { OverridableComponent, OverrideProps } from '@mui/types';
6+
import requirePropFactory from '../utils/requirePropFactory';
67
import { Theme, styled, useThemeProps, Breakpoint } from '../styles';
78

89
export type Grid2Slot = 'root';
@@ -251,4 +252,18 @@ Grid2.propTypes /* remove-proptypes */ = {
251252
wrap: PropTypes.oneOf(['nowrap', 'wrap-reverse', 'wrap']),
252253
} as any;
253254

255+
if (process.env.NODE_ENV !== 'production') {
256+
const Component = Grid2 as any;
257+
const requireProp = requirePropFactory('Grid2', Component);
258+
// eslint-disable-next-line no-useless-concat
259+
Component['propTypes' + ''] = {
260+
// eslint-disable-next-line react/forbid-foreign-prop-types
261+
...Component.propTypes,
262+
direction: requireProp('container'),
263+
size: requireProp('item'),
264+
spacing: requireProp('container'),
265+
wrap: requireProp('container'),
266+
};
267+
}
268+
254269
export default Grid2;

0 commit comments

Comments
 (0)