Working on a project with two separate .jsx
files each representing a different component.
The first one is called Blog.jsx
import React from "react";
import '../assets/css/blog.css';
export const Blog = () => (
<div>
<h1>Hello Blog</h1>
</div>
)
Accompanied by its own CSS file, blog.css
div { background: #ff481f; }
Then we have the second component, Landing.jsx
import React from "react";
import '../assets/css/landing.css'
export const Landing = () => (
<div>
<h1>Hello Landing</h1>
</div>
)
With its corresponding CSS file, landing.css
div { background: #86ff2b; }
Upon implementing routing and adding instances of both components in the App.js file (the main file in a React application), an issue surfaced. When navigating between components, the background color remains the same for both (only loading the styles from landing.css).
How can I resolve this problem so that each component utilizes its respective CSS file correctly and loads it accordingly?