2

I have a route set up for localhost:8080/song/9 where 9 is any number to dynamically load a page. This is the only type of route in my app that when I check the stylesheet.css it's completely empty. It successfully loads it but for some reason it's blank?

If I go to any other route it gets loaded successfully, which tends to make me believe it has something to do with dynamic routing in react. Here is my code set up for the routes.

return (
        <div className="container-fluid">
            <Router>
                <div>
                    <Route exact = {true} path={"/" } component = {Home}/>
                    <Route exact = {true} path={"/login"} component = {Login}/>
                    <Route exact = {true} path={"/register"} component ={Register}/>
                    <Route exact = {true} path={"/song/:songId"} component={SongEditor}/>
                    <Route exact = {true} path={"/create"} component={CreateSong}/>

                </div>
            </Router>

        </div>
    );

I've tried setting exact to false as well for the /song/songId path but I'm still having the issue

joe
  • 1,563
  • 4
  • 16
  • 35
  • 3
    If your stylesheet is linked like `href="style.css"`, changing the document location to `localhost:8080/song/9` will make the browser look for it in `localhost:8080/song/style.css`. You can rectify this by changing it to `href="/style.css"` –  Jun 07 '17 at 23:59
  • 2
    @ChrisG href="./css/stylesheet.css" to href="/css/stylesheet.css" did the trick!!! Thanks a lot. If you want to put that as an answer i'll accept it for you – joe Jun 08 '17 at 00:03
  • Your question is a duplicate: https://stackoverflow.com/questions/36923226/how-to-make-react-router-work-with-static-assets-html5-mode-history-api-and-ne and will probably get flagged and deleted soon –  Jun 08 '17 at 00:07
  • Possible duplicate of [How to make react router work with static assets, html5 mode, history API and nested routes?](https://stackoverflow.com/questions/36923226/how-to-make-react-router-work-with-static-assets-html5-mode-history-api-and-ne) – Preview Jun 08 '17 at 02:30

0 Answers0