Back to Fluentui

Ref component Migration guide

apps/public-docsite-v9/src/Concepts/Migration/FromV0/Components/Ref.mdx

4.40.2-hotfix2727 B
Original Source

import { Meta } from '@storybook/addon-docs/blocks';

<Meta title="Concepts/Migration/from v0/Components/Ref Migration" />

Ref component Migration guide

The Ref component from V0 is deprecated as it used the deprecated findDomNode utility from React. All V9 components support ref forwarding, so you can simply use useRef to the component.

Before:

tsx
import { Button } from '@fluentui/react-northstar';
const Component = ({ buttonRef }) => (
  <Ref innerRef={buttonRef}>
    <Button content="some content" />
  </Ref>
);

After:

tsx
import { Button } from '@fluentui/react-components';
const Component = () => {
  const ref = React.useRef(null);

  return <Button ref={ref}>some content</Button>;
};