DEV Community

Chantae P.
Chantae P.

Posted on

1

Help with React Router 😫

** Update: as of 1/25 I fixed the issue!!!! I had to add the 'basename' attribute to BrowserRouter:**

 <BrowserRouter basename="/shopping_cart">
....
<BrowserRouter/>
Enter fullscreen mode Exit fullscreen mode

Here's the live site


I am currently working on The Odin Projects "Shopping Cart" Assignment. Right now I am stuck on the Router section.

When I'm opening the project in VS code and using npm start to launch the application, this is how my screen looks:
When first opening the web application and this is my terminal after entering npm start
starting the application

For me to access the home page, I need to edit the url like so:
After manually removing 'shopping cart' from the URL

I'm trying to figure out what I did wrong but still don't understand what's going on. Here's my github repository. Any help is greatly appreciated. Thank you!

Sentry image

Hands-on debugging session: instrument, monitor, and fix

Join Lazar for a hands-on session where you’ll build it, break it, debug it, and fix it. You’ll set up Sentry, track errors, use Session Replay and Tracing, and leverage some good ol’ AI to find and fix issues fast.

RSVP here →

Top comments (2)

Collapse
 
giseleml profile image
Gisele Leonardi

That's because on your package.json the homepage attribute is set with "/shopping_cart". Remove that and it should work just fine.

Collapse
 
taepal467 profile image
Chantae P.

Thank you for responding!
I did try removing the '/shopping_cart' from the homepage attribute. It DID work when I'm building the project. But when I push my changes to github, the page is still blank.
Here's the live site with the changes made.

SurveyJS custom survey software

JavaScript Form Builder UI Component

Generate dynamic JSON-driven forms directly in your JavaScript app (Angular, React, Vue.js, jQuery) with a fully customizable drag-and-drop form builder. Easily integrate with any backend system and retain full ownership over your data, with no user or form submission limits.

Learn more

👋 Kindness is contagious

Please leave a ❤️ or a friendly comment on this post if you found it helpful!

Okay