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

Button: LinkComponent in Theme is not used #44389

Closed
BennyAlex opened this issue Nov 12, 2024 · 11 comments
Closed

Button: LinkComponent in Theme is not used #44389

BennyAlex opened this issue Nov 12, 2024 · 11 comments
Assignees
Labels
component: button This is the name of the generic UI component, not the React module! package: material-ui Specific to @mui/material

Comments

@BennyAlex
Copy link

BennyAlex commented Nov 12, 2024

Steps to reproduce

Previously in v5 I defined the LinkComponent inside theme

MuiButton: {
  defaultProps: {
    LinkComponent: MyLink
}

and it worked fine.

Not this doesnt work anymore.
I only see my link component when I do it manually for each button like:
https://mui.com/material-ui/integrations/routing/#button

Current behavior

No response

Expected behavior

No response

Context

No response

Your environment

npx @mui/envinfo
  Don't forget to mention which browser you used.
  Output from `npx @mui/envinfo` goes here.

Search keywords: LinkComponent

@BennyAlex BennyAlex added the status: waiting for maintainer These issues haven't been looked at yet by a maintainer label Nov 12, 2024
@sai6855
Copy link
Contributor

sai6855 commented Nov 12, 2024

Not this doesnt work anymore.

@BennyAlex what do you mean by, This doesn't work anymore? would you mind providing a repro in a sandbox please?

In this sandbox, i can see a being rendered when LinkComponent is passed in theme

https://stackblitz.com/edit/react-ndqyxk?file=Demo.tsx

@sai6855 sai6855 added component: button This is the name of the generic UI component, not the React module! status: waiting for author Issue with insufficient information package: material-ui Specific to @mui/material and removed status: waiting for maintainer These issues haven't been looked at yet by a maintainer labels Nov 12, 2024
@BennyAlex
Copy link
Author

BennyAlex commented Nov 12, 2024

@sai6855

https://stackblitz.com/edit/react-ndqyxk-run8w3?file=tsconfig.json,Router.jsx,RouterLink.jsx,Home.tsx,BaseRoute.jsx,Demo.jsx,index.tsx

(click go to demo)

This shows the error and also it looks like all default Props are ignored for some reason.

It should show outlined buttons by default and replace the link with the link from the url mapping.

@github-actions github-actions bot added status: waiting for maintainer These issues haven't been looked at yet by a maintainer and removed status: waiting for author Issue with insufficient information labels Nov 12, 2024
@BennyAlex
Copy link
Author

The same code worked fine with mui v5

@sai6855
Copy link
Contributor

sai6855 commented Nov 13, 2024

@BennyAlex Few imports are missing in your repro, can you add missing imports in this file and check again? https://stackblitz.com/edit/react-ndqyxk-run8w3?file=RouterLink.jsx

@siriwatknp siriwatknp added status: waiting for author Issue with insufficient information and removed status: waiting for maintainer These issues haven't been looked at yet by a maintainer labels Nov 13, 2024
@BennyAlex
Copy link
Author

@sai6855
https://stackblitz.com/edit/react-ndqyxk-run8w3?file=RouterLink.jsx,Home.tsx

should be there now, still the same behaviour

@github-actions github-actions bot added status: waiting for maintainer These issues haven't been looked at yet by a maintainer and removed status: waiting for author Issue with insufficient information labels Nov 13, 2024
@sai6855
Copy link
Contributor

sai6855 commented Nov 14, 2024

@BennyAlex I've updated version of @mui/material to 5.16.7 in you repor but still behaviour is same. when you say it was working in v5, which version were you on?

https://stackblitz.com/edit/react-ndqyxk-yvvn19?file=package.json

@sai6855 sai6855 added status: waiting for author Issue with insufficient information and removed status: waiting for maintainer These issues haven't been looked at yet by a maintainer labels Nov 14, 2024
@BennyAlex
Copy link
Author

BennyAlex commented Nov 14, 2024

I was also on the latest I think.
But it should work or whats the reason that the defaultProps are not applied?
The other stuff from theme seams to be applied correctly

@github-actions github-actions bot added status: waiting for maintainer These issues haven't been looked at yet by a maintainer and removed status: waiting for author Issue with insufficient information labels Nov 14, 2024
@sai6855
Copy link
Contributor

sai6855 commented Nov 14, 2024

@BennyAlex Found the issue, defaultProps are not being applied because you imported ThemeProvider from @emotion/react not from @mui/material in this file https://stackblitz.com/edit/react-ndqyxk-buu58f?file=BaseRoute.jsx

updated import in below sandbox, it's working now

https://stackblitz.com/edit/react-ndqyxk-buu58f?file=BaseRoute.jsx

@sai6855 sai6855 closed this as completed Nov 14, 2024
Copy link

This issue has been closed. If you have a similar problem but not exactly the same, please open a new issue.
Now, if you have additional information related to this issue or things that could help future readers, feel free to leave a comment.

Note

@BennyAlex How did we do? Your experience with our support team matters to us. If you have a moment, please share your thoughts in this short Support Satisfaction survey.

@github-actions github-actions bot removed the status: waiting for maintainer These issues haven't been looked at yet by a maintainer label Nov 14, 2024
@sai6855
Copy link
Contributor

sai6855 commented Nov 14, 2024

@BennyAlex feel free to re-open the issue, if you face any issues

@BennyAlex
Copy link
Author

@sai6855
great, thank you very much that helped me a lot :D

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
component: button This is the name of the generic UI component, not the React module! package: material-ui Specific to @mui/material
Projects
None yet
Development

No branches or pull requests

3 participants