-
-
Notifications
You must be signed in to change notification settings - Fork 1.4k
/
useGridState.ts
24 lines (22 loc) · 948 Bytes
/
useGridState.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
import * as React from 'react';
import { GridApiCommon } from '../../models/api/gridApiCommon';
import { GridApiCommunity } from '../../models/api/gridApiCommunity';
import { buildWarning } from '../../utils/warning';
const deprecationWarning = buildWarning([
'MUI: The hook useGridState is deprecated and will be removed in the next major version.',
'The two lines below are equivalent',
'',
'const [state, setState, forceUpdate] = useGridState(apiRef);',
'const { state, setState, forceUpdate } = apiRef.current',
]);
/**
* @deprecated Use `apiRef.current.state`, `apiRef.current.setState` and `apiRef.current.forceUpdate` instead.
*/
export const useGridState = <Api extends GridApiCommon = GridApiCommunity>(
apiRef: React.MutableRefObject<Api>,
) => {
if (process.env.NODE_ENV !== 'production') {
deprecationWarning();
}
return [apiRef.current.state, apiRef.current.setState, apiRef.current.forceUpdate] as const;
};