Styles not working with React-router

Styles not working with React-router
I’m trying to setup a react-router for my first React webapp, it seems to be working except that the css doesn’t load for my nested pages when I refresh the pages.

However it works for just one level e.g /dashboard but the css won’t load for /components/timer

Here is what my index.jsx file looks like

import './assets/plugins/morris/morris.css';
import './assets/css/bootstrap.min.css';
import './assets/css/core.css';
import './assets/css/components.css';
import './assets/css/icons.css';
import './assets/css/pages.css';
import './assets/css/menu.css';
import './assets/css/responsive.css';

render(
  <Router history={browserHistory}>
    <Route path="/" component={Dashboard}/>
    <Route path="/components/:name" component={WidgetComponent}/>
    <Route path="*" component={Dashboard}/>
  </Router>,
  document.getElementById('root')
);

How to solve this?

to this:

<head>
    <link rel="stylesheet" href="/style.css" ></link>
</head>

I’m not sure if the same thing would work for your import statements, but it is worth a shot.

FYI I’m using the project layout from create-react-app

Tags

What do you think?

Leave a Reply

Your email address will not be published. Required fields are marked *

Related articles

Contact us

Partner with Us for Comprehensive IT

We’re happy to answer any questions you may have and help you determine which of our services best fit your needs.

Your benefits:
What happens next?
1

We Schedule a call at your convenience 

2

We do a discovery and consulting meting 

3

We prepare a proposal 

Schedule a Free Consultation