React router stopped working after adding "createBrowserHistory" with saga

Viewed 439

I'm learning React.js and I struggled with the following problem:

My react app stopped working after adding "createBrowserHistory" with Saga.

Essentially, I want to redirect users to the Cart Page (/cart) when I click on "Add to Cart" button.

Example:

That is the home page:

enter image description here

When I click on "Add to Cart" button, it navigates to the "/cart" route. However, it doesn't show anything and, there is no error in the console.

enter image description here

I have made the following changes in my code:

Added history package:

enter image description here

Created history file:

enter image description here

Changed App.js file:

enter image description here

Changed saga file. I expect to navigate to the "/cart" route after doing some jobs...

enter image description here

The problem is here! I want to fix the problem in my saga file only.

I've created a Pull Request here, to reproduce the error. Feel free to have a look at this.

https://github.com/willianfalbo/online-shoes-app/pull/1

I'm willing to bounty someone who creates a PR for me. I will also accept your answer here!

1 Answers

Seems like react-router 5x version are only compatible with history.4x.

Downgrading the history version to 4.2.0 works.

Related