Skip to content

[migration] How to solve conflict between my project using v5 and third-party packages using v4? #31211

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

Closed
RandyLiu6410 opened this issue Feb 25, 2022 · 5 comments
Labels
support: question Community support but can be turned into an improvement v5.x migration

Comments

@RandyLiu6410
Copy link

My project has just been updated to Mui v5 (https://mui.com/). And one of used package react-page (https://github.com/react-page/react-page) in the project uses Mui v4 (https://v4.mui.com/). And some conflicts just showed up. When I use the module importing the react-page, the style sheet of mui v4 covered the current style sheet of mui v5. How can I prevent mui v4 from covering all style sheets and make sure mui v5 is still working as before?

@danilo-leal danilo-leal changed the title How to solve conflict between my project using mui5 and package using mui4? [migration] How to solve conflict between my project using v5 and third-party packages using v4? Feb 28, 2022
@danilo-leal danilo-leal added v5.x migration support: question Community support but can be turned into an improvement labels Feb 28, 2022
@embeddedt
Copy link
Contributor

I have the same question. I'm considering upgrading to MUI v5, but one of my dependencies still relies on Material-UI v4 (and likely won't be updated soon), so I won't be able to upgrade unless the two versions can run side-by-side.

@RandyLiu6410
Copy link
Author

I solved by generating prefix classname of v4 components.

`import * as React from 'react';
import { StylesProvider, createGenerateClassName } from '@material-ui/styles';

const generateClassName = createGenerateClassName({
productionPrefix: 'c',
});

export default function App() {
return ...;
}`

@embeddedt
Copy link
Contributor

Thanks, this worked for me. It also appears to match the official approach recommended for the opposite scenario (third-party v5 dependency in a v4 project): https://mui.com/components/data-grid/migration-v4/

@Goytai
Copy link

Goytai commented Nov 14, 2024

Thanks guys, this worked for me too.

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
support: question Community support but can be turned into an improvement v5.x migration
Projects
None yet
Development

No branches or pull requests

5 participants