Skip to content
Advertisement

Tag: react-router-dom

I can’t display nested route in different view

I’ve been trying to display a component in a different view from the parent component but what I get is the two components displayed in the same view, first parent component, and right below, child component when the Link is clicked. It’s a simple shopping cart (/cart) and after clicking Pay you should be redirected to checkout (/cart/checkout) view, nevertheless

Why use history.push or some other method from react-router-dom instead of just assigning the path to window.location.pathname?

It seems easier to me when I need to navigate somewhere in my code to just assign the path where I want to go to window.location.pathname. Is there any disadvantage to doing this? Answer Because window.location.pathname triggers a reload, defeating the entire purpose of react-router, while history.push() just changes the url and doesn’t reload. Not reloading the entire page is

How to properly use useHistory () from react-router-dom?

How to use useHistory() correctly? I can’t make the transition from one react component to another. According to the instructions from the React documentation and also here on Stack Overflow, I cannot make the transition from App.js to MyComponent.js. For example – I am trying I also tested this example, but the output throws the following error when the button

req.query is empty and req.url is not complete using react router and express

When the page URL is http://localhost:3000/verify?token=something and I make a GET request using fetch, when I hit the server, req.url is “/verify” instead of “verify?token=something”, also the req.query object is empty The client is running on port 3000 and the server on port 5000. I’m using a proxy in package.json on the client-side. Have been scratching my head for some

Advertisement