root-ref

v4.9.10arrow_drop_down
v4.9.10
v4.5.2
v3.9.2
STATUS
Passing
DOWNLOADS
6,369
LICENSE
MIT
VISIBILITY
Public
PUBLISHED
4 years ago
SIZE
3 KB
⚠️⚠️⚠️ If you want the DOM element of a Material-UI component check out [FAQ: How can I access the DOM element?
2 contributors
Install root-ref as a package?
Copied
npm i @bit/mui-org.material-ui.root-ref
Set Bit as a scoped registryLearn more
npm config set '@bit:registry' https://node.bit.cloud
Component Example
React
React
Vue
Angular
React Native
Add dependency... help_outline
Just
import
any of the 1 million components
and packages in Bit or NPM to the example.
import Button from '@bit/grommet.grommet.button';
import Lodash from 'lodash';
toggle layout
chevron_left
chevron_right

⚠️⚠️⚠️ If you want the DOM element of a Material-UI component check out FAQ: How can I access the DOM element? first.

This component uses findDOMNode which is deprecated in React.StrictMode.

Helper component to allow attaching a ref to a wrapped element to access the underlying DOM element.

It’s highly inspired by https://github.com/facebook/react/issues/11401#issuecomment-340543801. For example:

import React from 'react';
import RootRef from '@material-ui/core/RootRef';

function MyComponent() {
  const domRef = React.useRef();

  React.useEffect(() => {
    console.log(domRef.current); // DOM node
  }, []);

  return (
    <RootRef rootRef={domRef}>
      <SomeChildComponent />
    </RootRef>
  );
}

API:

RootRef ()

⚠️⚠️⚠️ If you want the DOM element of a Material-UI component check out FAQ: How can I access the DOM element? first.

This component uses findDOMNode which is deprecated in React.StrictMode.

Helper component to allow attaching a ref to a wrapped element to access the underlying DOM element.

It’s highly inspired by https://github.com/facebook/react/issues/11401#issuecomment-340543801. For example:

import React from 'react';
import RootRef from '@material-ui/core/RootRef';

function MyComponent() {
const domRef = React.useRef();

React.useEffect(() => {
console.log(domRef.current); // DOM node
}, []);

return (
<RootRef rootRef={domRef}>
<SomeChildComponent />
</RootRef>
);
}
Properties
NameTypeDescription
children
(required)
element

The wrapped element.

rootRef
custom

A ref that points to the first DOM node of the wrapped element.

Help and resources