0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

mui/materialの Menuコンポーネント「'PaperProps' is deprecated.」メッセージ解消

Posted at

事象

過去バージョン想定で書かれたMUI(Material UI)のコンポーネントに対して、VSCode上で以下のメッセージが表示されていた

メッセージ内容

'PaperProps' is deprecated.ts(6385)
Popover.d.ts(144, 6): The declaration was marked as deprecated here.
(property) PaperProps?: Partial<PaperProps<React.ElementType<any, keyof React.JSX.IntrinsicElements>>> | undefined
Props applied to the Paper element.

This prop is an alias for slotProps.paper and will be overriden by it if both are used.

@deprecated — Use slotProps.paper instead.

@default

{}

対象コンポーネントの実装

        <Menu
            anchorEl={mobileMenuAnchor}
            open={Boolean(mobileMenuAnchor)}
            onClose={handleMobileMenuClose}
            PaperProps={{   // ここでメッセージが出る
                style: {
                    maxHeight: '100%',
                    width: '250px',
                },
            }}
        >

事象発生時のバージョン

  • mui/material: 6.1.10

対策

メッセージ内容に従い、deprecatedとなったPaperProps をslotPropsに書き換え、メッセージが消えることを確認(動作も問題なし)

        <Menu
            anchorEl={mobileMenuAnchor}
            open={Boolean(mobileMenuAnchor)}
            onClose={handleMobileMenuClose}
            slotProps={{
                paper: {
                    style: {
                        maxHeight: '100%',
                        width: '250px',
                    }
                },
            }}

slotPropsの詳細は下の公式ドキュメントを参照
React Menu components and hooks - Base UI

0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?