<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: Jose Robles</title>
    <description>The latest articles on DEV Community by Jose Robles (@jrrobles979).</description>
    <link>https://dev.to/jrrobles979</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F773254%2F93aa36cd-0353-4b3c-a613-2c55573eaa5b.jpg</url>
      <title>DEV Community: Jose Robles</title>
      <link>https://dev.to/jrrobles979</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/jrrobles979"/>
    <language>en</language>
    <item>
      <title>react app, assets path change</title>
      <dc:creator>Jose Robles</dc:creator>
      <pubDate>Sun, 12 Dec 2021 19:23:40 +0000</pubDate>
      <link>https://dev.to/jrrobles979/react-app-assets-path-change-4k60</link>
      <guid>https://dev.to/jrrobles979/react-app-assets-path-change-4k60</guid>
      <description>&lt;p&gt;Hello, Im helping a friend to solve an issue a previous developer left, but Im new on React, so I don't know how to solve this issue:&lt;/p&gt;

&lt;p&gt;He was integrating a html template he bought with React for his store site (he sells courses). The problem is when we click and open a detail of tutor or a detail of a course, the inner Source structure change, making the app lost the path to the '/assets' folder, making that all the pages to lost the styling.&lt;/p&gt;

&lt;p&gt;for most of the pages this is the structure, and works fine, for example the checkout page:&lt;br&gt;
&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--ZEI7k3NQ--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/mzy1qzuh7fd3h86skwrg.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--ZEI7k3NQ--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/mzy1qzuh7fd3h86skwrg.png" alt="Image description" width="340" height="190"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;but when I enter on a detail, the structure changes:&lt;br&gt;
&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--x8QREjCT--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/h7w64gpggvgth31mfsde.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--x8QREjCT--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/h7w64gpggvgth31mfsde.png" alt="Image description" width="293" height="223"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;As you can see, on the detail, a 'tutorDetail' folder is created and inside is the 'localhost:3000/tutorDetail/assets' folder with the css and js, while the original 'localhost:3000/asset' folder is now empty, after that when I go to any other page, all are a white mess of words and images.&lt;/p&gt;

&lt;p&gt;The site was builded on a component called 'Home' and is build like this:&lt;/p&gt;

&lt;p&gt;&lt;code&gt;return (&lt;br&gt;
        &amp;lt;Fragment&amp;gt;&lt;br&gt;
            &amp;lt;Header /&amp;gt;&lt;br&gt;
                &amp;lt;div className="sg-page-content"&amp;gt;&lt;br&gt;
                    &amp;lt;div className="sg-section"&amp;gt;&lt;br&gt;
                        &amp;lt;div className="section-content sg-filter-content list-view-tab section-padding"&amp;gt;&lt;br&gt;
                            &amp;lt;div className="container"&amp;gt;&lt;br&gt;
                                &amp;lt;Content /&amp;gt;&lt;br&gt;
                            &amp;lt;/div&amp;gt;&lt;br&gt;
                        &amp;lt;/div&amp;gt;&lt;br&gt;
                    &amp;lt;/div&amp;gt;&lt;br&gt;
                &amp;lt;/div&amp;gt;&lt;br&gt;
            &amp;lt;Footer /&amp;gt;&lt;br&gt;
        &amp;lt;/Fragment&amp;gt;&lt;br&gt;
    )&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;and in the 'Content' component is where all the pages are render:&lt;/p&gt;

&lt;p&gt;&lt;code&gt;return (&lt;br&gt;
        &amp;lt;Router&amp;gt;&lt;br&gt;
            &amp;lt;Switch&amp;gt;&lt;br&gt;
                &amp;lt;Route path="/courses" component={Courses}/&amp;gt;&lt;br&gt;
                &amp;lt;Route path="/school" component={Schools}/&amp;gt;&lt;br&gt;
                &amp;lt;Route path="/tutordetail/:tutor" component={TutorDetail}/&amp;gt;&lt;br&gt;
                &amp;lt;Route path="/blog" component={Blog}/&amp;gt;&lt;br&gt;
                &amp;lt;Route path="/coursedetails/:course" component={CourseDetail} /&amp;gt;&lt;br&gt;
                &amp;lt;Route path="/schooldetails/:school" component={SchoolDetail} /&amp;gt;&lt;br&gt;
                &amp;lt;Route path="/blogdetail/:idPost" component={BlogDetail}/&amp;gt;&lt;br&gt;
                &amp;lt;Route path="/login" component={Login}/&amp;gt;&lt;br&gt;
                &amp;lt;Route path="/register" component={Registro}/&amp;gt;&lt;br&gt;
                &amp;lt;Route path="/cart" component={Cart}/&amp;gt;&lt;br&gt;
                &amp;lt;Route path="/checkout" component={Checkout}/&amp;gt;&lt;br&gt;
                &amp;lt;Route path="/" component={Index}/&amp;gt;&lt;br&gt;
            &amp;lt;/Switch&amp;gt;&lt;br&gt;
        &amp;lt;/Router&amp;gt;&lt;br&gt;
    )&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;I also noticed the next:&lt;/p&gt;

&lt;p&gt;I tried to 'fix' this editing the HTML manually with the developers tool changing the inner path to the css and js for example:&lt;/p&gt;

&lt;p&gt;from&lt;/p&gt;

&lt;p&gt;&lt;code&gt;&amp;lt;link rel="stylesheet" href="./assets/css/main.css"&amp;gt;&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;to &lt;/p&gt;

&lt;p&gt;&lt;code&gt;&amp;lt;link rel="stylesheet" href="../assets/css/main.css"&amp;gt;&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;and this fix the looks, but I don't know how to solve this from React to tell all the pages to use the same path to '/assets'&lt;/p&gt;

&lt;p&gt;can you guide me on how to solve this?&lt;/p&gt;

</description>
      <category>react</category>
      <category>beginners</category>
      <category>css</category>
    </item>
  </channel>
</rss>
