Skip to content

Commit

Permalink
[core] Rely on immutable ref when possible (#40831)
Browse files Browse the repository at this point in the history
  • Loading branch information
oliviertassinari authored Jan 29, 2024
1 parent 147db41 commit 4ee5046
Show file tree
Hide file tree
Showing 4 changed files with 4 additions and 4 deletions.
2 changes: 1 addition & 1 deletion packages/mui-base/src/unstable_useModal/useModal.ts
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ export function useModal(parameters: UseModalParameters): UseModalReturnValue {

// @ts-ignore internal logic
const modal = React.useRef<{ modalRef: HTMLDivElement; mount: HTMLElement }>({});
const mountNodeRef = React.useRef<null | HTMLElement>(null);
const mountNodeRef = React.useRef<HTMLElement | null>(null);
const modalRef = React.useRef<HTMLDivElement>(null);
const handleRef = useForkRef(modalRef, rootRef);
const [exited, setExited] = React.useState(!open);
Expand Down
2 changes: 1 addition & 1 deletion packages/mui-material-next/src/Menu/Menu.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ const MenuInner = React.forwardRef(function Menu(inProps, ref) {
const theme = useTheme();
const isRtl = theme.direction === 'rtl';

const listRef = React.useRef<HTMLElement | null>(null);
const listRef = React.useRef<HTMLElement>(null);

// TODO v6: Handle the rest of the props from the MenuListProps prop
const {
Expand Down
2 changes: 1 addition & 1 deletion packages/mui-material-next/src/MenuItem/MenuItem.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -183,7 +183,7 @@ const MenuItem = React.forwardRef(function MenuItem<RootComponentType extends Re
[context.dense, dense, disableGutters],
);

const menuItemRef = React.useRef<HTMLElement | null>(null);
const menuItemRef = React.useRef<HTMLElement>(null);
const handleRef = useForkRef(menuItemRef, ref);

const { getRootProps, disabled, focusVisible, highlighted } = useMenuItem({
Expand Down
2 changes: 1 addition & 1 deletion packages/mui-material-next/src/Option/Option.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -180,7 +180,7 @@ const Option = React.forwardRef(function Option<RootComponentType extends React.
[context.dense, dense, disableGutters],
);

const optionRef = React.useRef<HTMLElement | null>(null);
const optionRef = React.useRef<HTMLElement>(null);
const handleRef = useForkRef(optionRef, ref);

const { getRootProps, disabled, focusVisible, highlighted } = useMenuItem({
Expand Down

0 comments on commit 4ee5046

Please sign in to comment.