Skip to content

Commit

Permalink
[docs] Fix missing JSX closing tag in Tooltip docs (#34064)
Browse files Browse the repository at this point in the history
* Fix missing close tag

Signed-off-by: Snêu <39024711+hoangph271@users.noreply.github.com>

* yarn prettier

Signed-off-by: Snêu <39024711+hoangph271@users.noreply.github.com>
Co-authored-by: ZeeshanTamboli <zeeshan.tamboli@gmail.com>
  • Loading branch information
hoangph271 and ZeeshanTamboli committed Aug 25, 2022
1 parent a94977f commit 2b2cc37
Showing 1 changed file with 15 additions and 7 deletions.
22 changes: 15 additions & 7 deletions docs/data/material/components/tooltips/tooltips.md
Expand Up @@ -47,14 +47,18 @@ If the child is a custom React element, you need to make sure that it spreads it
```jsx
const MyComponent = React.forwardRef(function MyComponent(props, ref) {
// Spread the props to the underlying DOM element.
return <div {...props} ref={ref}>Bin</div>
return (
<div {...props} ref={ref}>
Bin
</div>
);
});

// ...

<Tooltip title="Delete">
<MyComponent>
</Tooltip>
<MyComponent />
</Tooltip>;
```

You can find a similar concept in the [wrapping components](/material-ui/guides/composition/#wrapping-components) guide.
Expand All @@ -66,9 +70,13 @@ class MyComponent extends React.Component {
render() {
const { innerRef, ...props } = this.props;
// Spread the props to the underlying DOM element.
return <div {...props} ref={innerRef}>Bin</div>
return (
<div {...props} ref={innerRef}>
Bin
</div>
);
}
};
}

// Wrap MyComponent to forward the ref as expected by Tooltip
const WrappedMyComponent = React.forwardRef(function WrappedMyComponent(props, ref) {
Expand All @@ -78,8 +86,8 @@ const WrappedMyComponent = React.forwardRef(function WrappedMyComponent(props, r
// ...

<Tooltip title="Delete">
<WrappedMyComponent>
</Tooltip>
<WrappedMyComponent />
</Tooltip>;
```

## Triggers
Expand Down

0 comments on commit 2b2cc37

Please sign in to comment.