To combine React Router’s Link with Material-UI’s button, you should use the Button
component from Material-UI instead of FlatButton
and wrap it inside the Link
component. Here’s how you can do it:
jsximport React from 'react';
import { Link } from 'react-router-dom';
import Button from '@material-ui/core/Button';
class MyComponent extends React.Component {
render() {
const { url, name } = this.props;
return (
<Link to={url}>
<Button>{name}Button>
Link>
);
}
}
export default MyComponent;
In this example, Button
from Material-UI is used inside the Link
component to create a button that navigates to the specified URL. Make sure to wrap the Button
component directly inside the Link
component, and not inside any other element.
Also, ensure that you have installed the required packages (react-router-dom
and @material-ui/core
) and imported them correctly in your file.
المزيد من المعلومات
لا توجد مزيد من المعلومات في السياق الحالي. تقدم الرسالة بالفعل شرحًا كافيًا لكيفية دمج مكونات React Router و Material-UI. إذا كنت بحاجة إلى مزيد من التفاصيل أو توجيهات حول هذا الموضوع أو أي شيء آخر، فلا تتردد في سؤالي.