NA +91-8727899942 thecoderjob@gmail.com

CHAPTER - 42

404 Page Not Found and Redirect

With the help of this code redirect to custom page when the url of your project not found.

Here's is the Code !!

import React from "react"
import Home from "./Home"
import NotFonund from "./NotFonund"

import { BrowserRouter as Routes, Route, Link , Navigate} from "react-router-dom";

function RouteTest(){
          <BrowserRouter>
             <Routes>
	         <Route to="/home" element={<Home />} />
		 <Route to="/*" element={<NotFonund/>} /> 
                 OR
                 <Route to="/*" element={<Navigate to="/home">} /> 
            </Routes>
	</BrowserRouter>
}

Chapter 41

React Router - Links, NaBar, anchor Tag

Previous chapter

Chapter 43

Dynamic Routing with params

Next chapter

Get In Touch

NA

thecoderjob@gmail.com

+91-8727899942

Popular Links

© www.thecoderjob.com. All Rights Reserved.               Designed by HTML Codex