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:
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.
I have made the following changes in my code:
Added history package:
Created history file:
Changed App.js file:
Changed saga file. I expect to navigate to the "/cart" route after doing some jobs...
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!
Seems like react-router 5x version are only compatible with history.4x.
Downgrading the history version to 4.2.0 works.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.