UNPKG

1.21 kBTypeScriptView Raw
1import * as React from 'react';
2
3export interface RootRefProps<T = any> {
4 rootRef?: ((instance: T | null) => void) | React.RefObject<T>;
5}
6
7/**
8 * ⚠️⚠️⚠️
9 * If you want the DOM element of a Material-UI component check out
10 * [FAQ: How can I access the DOM element?](https://mui.com/getting-started/faq/#how-can-i-access-the-dom-element)
11 * first.
12 *
13 * This component uses `findDOMNode` which is deprecated in React.StrictMode.
14 *
15 * Helper component to allow attaching a ref to a
16 * wrapped element to access the underlying DOM element.
17 *
18 * It's highly inspired by <https://github.com/facebook/react/issues/11401#issuecomment-340543801>.
19 * For example:
20 *
21 * ```jsx
22 * import React from 'react';
23 * import RootRef from '@material-ui/core/RootRef';
24 *
25 * function MyComponent() {
26 * const domRef = React.useRef();
27 *
28 * React.useEffect(() => {
29 * console.log(domRef.current); // DOM node
30 * }, []);
31 *
32 * return (
33 * <RootRef rootRef={domRef}>
34 * <SomeChildComponent />
35 * </RootRef>
36 * );
37 * }
38 * ```
39 *
40 * @deprecated
41 * API:
42 *
43 * - [RootRef API](https://mui.com/api/root-ref/)
44 */
45declare const RootRef: React.ComponentType<RootRefProps>;
46
47export default RootRef;
48
\No newline at end of file