0
¿How works urls with React.js?
Hello, I have a question, I am making a web page with react and I have applied a navigation bar using react router, link, etc. and everything works correctly what happens is that if I enter the url manually it does not load the react page, I understand that It happens because I am making a request to a server path that does not exist. How do I get the page to load? Do i have to apply ssr or is there another way? Thank you very much to all.
4 Respostas
+ 5
You need to have the url pattern to match a route so react router knows which component to render for the given route.
If you could share an example url and the code for your routes it would make it easier for us to help
https://reacttraining.com/react-router/web
you can see how it's done on some of the examples:
Basic
URL Parameters
Route Config
and probably others
+ 2
Next.js has easy way to use react for ssr.
0
I understand but if I write the url the component doesn't render and I get the message cannot get "/login" url in the browser. I have a image with my navigation but I can't paste it here.
0
For page request from server, you can use window.location.href ="/path/link".