Skip to content

Commit

Permalink
Add comments
Browse files Browse the repository at this point in the history
  • Loading branch information
arminmeh committed Jan 21, 2025
1 parent af0006a commit 04da28e
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 1 deletion.
1 change: 1 addition & 0 deletions packages/x-data-grid/src/hooks/utils/useGridApiRef.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,5 @@ import { GridApiCommunity } from '../../models/api/gridApiCommunity';
* Hook that instantiate a [[GridApiRef]].
*/
export const useGridApiRef = <Api extends GridApiCommon = GridApiCommunity>(): ApiRef<Api> =>
// TODO v8: initialize with null (see https://github.com/mui/mui-x/issues/16135#issuecomment-2589395230 and https://github.com/mui/mui-x/issues/16000#issuecomment-2567820735)
useRef<Api>({} as Api);
4 changes: 3 additions & 1 deletion packages/x-internals/src/apiRef/apiRef.tsx
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
import * as React from 'react';
import reactMajor from '../reactMajor';

// in React 19 useRef requires a parameter, so () => infer R will not match anymore
export type ApiRef<T> = typeof React.useRef<T> extends () => infer R
? R extends React.MutableRefObject<infer M | undefined>
? React.MutableRefObject<M>
? // In v7 we remove the possibility of undefined for MutableRefObject (see https://github.com/mui/mui-x/issues/16135#issuecomment-2589395230)
React.MutableRefObject<M>
: R
: React.RefObject<T>;

Expand Down

0 comments on commit 04da28e

Please sign in to comment.