If app starts in certain paths redirect to root
See original GitHub issueThis issue requires knowledge of react
and react-router
.
Thank you for your help ❤️
What is this project?
DAV (Decentralized Autonomous Vehicles) is a new foundation working to build an open-source infrastructure for autonomous vehicles (cars, drones, trucks, robots, and all the service providers around them) to communicate and transact with each other over blockchain.
Missions
The DAV project you are looking at is Missions. Missions is the client facing side of the marketplace connecting DAV users looking to ship packages, with autonomous vehicles such as drones.
How you can help
Missions is a web app built using React and React Router. When a user clicks links in the app the url gets updated. If the user refreshes the page when the url is pointing at certain routes (or enters those urls directly) we do not have all the information needed to display those pages, and would want to redirect the user to the root route instead.
Add code to a central location that will check the current url when the app loads, and if it is /searching
push the /
url to the history (which will cause it to navigate there). In the future we will have more conditions here which will cause it to navigate. My initial instinct is to do this in the App
component (as it has access to the router, and it is the first component to load (after its wrapper: Main
)).
To run the project locally, you will need to clone it, run npm run
, and then visit http://localhost:3333/
. Detailed instructions are below:
Contributing to Missions
- Fork the repository from the Missions GitHub page.
- Clone a copy to your local machine with
$ git clone git@github.com:YOUR-GITHUB-USER-NAME/missions.git
- Make sure you have node.js and npm installed on your machine. You can use this guide for help.
- Install all of the project’s dependencies with npm.
$ cd missions; npm install
- Run
gulp watch:js
to start a local server and watch your local code for changes. The server will restart automatically every time you change the code. - Code! code! code!
- Before committing your code, run
gulp
one last time and make sure no errors (including linting errors) are thrown. - Once you’ve made sure all your changes work correctly, and committed all your changes, push your local changes back to github with
$ git push -u origin master
- Visit your fork on GitHub.com (https://github.com/YOUR-USER-NAME/missions) and create a pull request for your changes.
- Make sure your pull request describes exactly what you changed and references this issue (include the issue number in the title like this:
#26
)
Issue Analytics
- State:
- Created 6 years ago
- Comments:9 (5 by maintainers)
Top GitHub Comments
Hey I owe an update on this one. Working on it has essentially just been going through learning react and react-router docs, making notes and going through working with some examples. At first i just wrote a couple of redirects which was pretty hacky and not a sustainable solution. I think this issue could actually be solved by using browserhistory with a Switch and passing the previousURL to the next path using nested routes… i’m going to try experimenting with it this week and report back
Hey all I’ll give this a shot and check in with an update soon.