Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[docs] Fix missing JSX closing tag in Tooltip docs #34064

Merged
merged 3 commits into from Aug 25, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
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