Skip to content

Commit

Permalink
[Grid2] Add compatible props warning (#43801)
Browse files Browse the repository at this point in the history
  • Loading branch information
k-rajat19 authored Oct 3, 2024
1 parent ce9a6e6 commit 1765c7b
Showing 1 changed file with 15 additions and 0 deletions.
15 changes: 15 additions & 0 deletions packages/mui-material/src/Grid2/Grid2.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import PropTypes from 'prop-types';
import { createGrid as createGrid2 } from '@mui/system/Grid';
import { SxProps, SystemProps } from '@mui/system';
import { OverridableComponent, OverrideProps } from '@mui/types';
import requirePropFactory from '../utils/requirePropFactory';
import { Theme, styled, useThemeProps, Breakpoint } from '../styles';

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

if (process.env.NODE_ENV !== 'production') {
const Component = Grid2 as any;
const requireProp = requirePropFactory('Grid2', Component);
// eslint-disable-next-line no-useless-concat
Component['propTypes' + ''] = {
// eslint-disable-next-line react/forbid-foreign-prop-types
...Component.propTypes,
direction: requireProp('container'),
size: requireProp('item'),
spacing: requireProp('container'),
wrap: requireProp('container'),
};
}

export default Grid2;

0 comments on commit 1765c7b

Please sign in to comment.