A
A
Akmal Islamov2019-11-22 17:27:45
Frontend
Akmal Islamov, 2019-11-22 17:27:45

Not getting to the right page in React Router Dom?

Good evening gentlemen.
There is a React site that uses react-router-dom.
Let's say a person went there, went to other pages and copied the url of the page and threw it off to someone, and the url was something like this mysite.com/contacts . When a person types this url, he gets 404.
To open the page (that is, the contacts component), the user needs to go to it from the main page. How to make it possible to immediately open the desired page (Component).
(I apologize for the bad explanation, I don't know Russian well)))

Answer the question

In order to leave comments, you need to log in

2 answer(s)
A
abberati, 2019-11-22
@Akmal_23ram

You need to set up your server. Now it is trying to process the request and does not find such a route. This happens before the front is loaded. Set it up so that the server sends your index.html to any request - everything will work.

D
Dolerum, 2019-11-22
@Dolerum

Apparently contacts appear due to pushing in history, without specific rendering of the component with paths.
Go to the APP, there look for the contacts component, or something that renders contacts, a container for example - write something like
Something like this, if I correctly understood the essence of the problem.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question