Replies: 2 comments 1 reply
-
|
It's a tough question to answer generically. The answer could vary depending on the specifics of your project. Not sure you're gonna get much guidance on this unfortunately |
Beta Was this translation helpful? Give feedback.
-
Solution: Use CSS Modules or CSS-in-JS to Avoid ConflictsGreat question! CSS conflicts when merging two CRA projects is a common issue. Here are the best solutions: Option 1: CSS Modules (Recommended for CRA)Create React App has built-in CSS Modules support—no extra setup needed! // Dashboard.module.css
.navOpen { padding: 20px; }
.wrapper { max-width: 1200px; }
// Dashboard.jsx
import styles from "./Dashboard.module.css";
export function Dashboard() {
return (
<div className={styles.navOpen}>
<div className={styles.wrapper}>Content</div>
</div>
);
}Why this works: CSS is scoped to the component. Zero global conflicts! Option 2: CSS Namespacing with BEM ConventionAdd prefixes to prevent cascade conflicts: .dashboard__nav-open { padding: 20px; }
.features__nav-open { padding: 20px; }Option 3: CSS-in-JSLibraries like ✅ Recommended Path
CSS Modules solves 95% of merge conflicts—highly recommended! See: https://create-react-app.dev/docs/adding-a-css-modules-stylesheet/ |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
I've been searching a lot about merging two different project and I've tried lots of ways to merge two different project(dashboard and some main pages) with redux , putting ./src's of two project beside each other and etc ...
but the thing happened in all the process of merging is css conflict which my ui elements gets messy
this is my index.js of dashboard
Beta Was this translation helpful? Give feedback.
All reactions