React Router v4 Tutorial - #4 Switch, Redirect, & Fallback Routes

preview_player
Показать описание
If you send out a request to a gibberish URL, how'd you expect the web app to respond? Typically, a website would either spit back a 404 Not Found template, or first redirect to a dedicated page (e.g. /404) and then display the Not Found message. Sounds sensible, but where does React Router come in?

To make a redirect, you can use the Redirect component. When returned from then render() method, it will navigate to the new location specified under the "to" prop. Note that by default, Redirect simulates an HTTP (i.e. server) redirect in that it replaces the current location with a given path, thereby clearing the originating page from the history stack.

Рекомендации по теме
Комментарии
Автор

These are a fastastic series on React Router v4. Well done, really informative and interesting. Following and sharing for sure!

davemitten
Автор

You are a stunningly fluent developer. Your ability to verbalize what you are doing while you're doing it is amazing. I have to slow the video to 75% speed and watch multiple times to catch everything. Do you practice these presentations beforehand? I'm curious to know what your process is. I don't get the feeling that you're planning what you're saying. It feels like it's in the moment.


I also really appreciate that you start from a very simple base and build up. I found your channel while trying to work with Material UI. Most tutorials assume too much knowledge/understanding on the part of the viewer. This series starts from nothing and shows how to incorporate Material UI into a very basic un-styled React app.


Thank you!!!

scottb
Автор

Good day Sir, how do you deal on situations in which you type a specific path in the url that leads or should show a component?. It works when I religiously click the link with the specific route path, however when I try to refresh the page or type something specific on the url, nothing is showing up...

blayke
Автор

is this code on your git repository provided in the video? I tried to find writers-blog but no sucess...

brunofilgueiras
Автор

Hey, can you implement mini-drawer with router.

daysnight
Автор

Hello Sir, I am facing some issue in my project, i have used BrowserRouter for Route but after create build then run on browser and after refresh page 'object not found error showing' but i have used HashRouter for Route then after create build run on browser, project run perfect. Please help me to solve this error 'object not found after page refresh'

sneharajput
Автор

I'm having an issue, after uploading my SPA and typing a route in the browser it goes to a 404 not defined by me, I am using Switch, and have tried Route Path="*" and both work offline but not online, what can I do?

yarapolana
welcome to shbcf.ru