Skip to content

Commit 0e55ea4

Browse files
Add section to pass any other React components
1 parent 66d330a commit 0e55ea4

File tree

1 file changed

+18
-1
lines changed

1 file changed

+18
-1
lines changed

docs/data/material/guides/composition/composition.md

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,23 @@ The following example will render the `List` component with a `<menu>` element a
4747

4848
This pattern is very powerful and allows for great flexibility, as well as a way to interoperate with other libraries, such as your favorite routing or forms library.
4949

50+
### Passing other React components
51+
52+
You can pass any other React component to `component` prop. For example, you can pass `Link` component from `react-router-dom`:
53+
54+
```tsx
55+
import { Link } from 'react-router-dom';
56+
import Button from '@mui/material/Button';
57+
58+
function Demo() {
59+
return (
60+
<Button component={Link} to="/react-router">
61+
React router link
62+
</Button>
63+
);
64+
}
65+
```
66+
5067
### With TypeScript
5168

5269
To be able to use the `component` prop, the type of the props should be used with type arguments. Otherwise, the `component` prop will not be present.
@@ -71,7 +88,7 @@ You can find a code example with the Button and react-router-dom in [these demos
7188

7289
### Generic
7390

74-
It's also possible to have a generic `CustomComponent` which will accept any React component, and HTML elements.
91+
It's also possible to have a generic custom component which will accept any React component, and HTML elements.
7592

7693
```ts
7794
function GenericCustomComponent<C extends React.ElementType>(

0 commit comments

Comments
 (0)