From 1765c7b4e2895720467ff8e8874eec355f74b505 Mon Sep 17 00:00:00 2001 From: Rajat Date: Thu, 3 Oct 2024 13:21:10 +0530 Subject: [PATCH] [Grid2] Add compatible props warning (#43801) --- packages/mui-material/src/Grid2/Grid2.tsx | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/packages/mui-material/src/Grid2/Grid2.tsx b/packages/mui-material/src/Grid2/Grid2.tsx index 3aeb961de5ff97..dfa589fdaa1693 100644 --- a/packages/mui-material/src/Grid2/Grid2.tsx +++ b/packages/mui-material/src/Grid2/Grid2.tsx @@ -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'; @@ -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;