NA +91-8727899942 thecoderjob@gmail.com

CHAPTER - 43

Dynamic Routing with params

Helpfull for display data for multiple params

Here's is the Code !!

import React from "react";
import { BrowserRouter as Router, Route, Switch } from "react-router-dom";

import RouteTest from "./RouteTest";
import About from "./About";

const Routes = () => {
  return (
    <Router>
      <Switch>
        <Route exact path="/page/:params" component={RouteTest} />
      </Switch>
    </Router>
  );
};
export default Routes;

// Another component
import React from "react";
import { useParams } from "react-router-dom";

const RouteTest = () => {
  let { params } = useParams();

  return(
    <> 
      Params Detail: { params }
    <>
  )
};

export default RouteTest;

Chapter 42

404 Page Not Found and Redirect

Previous chapter

Chapter 44

SearchParams and setSearchParmas

Next chapter

Get In Touch

NA

thecoderjob@gmail.com

+91-8727899942

Popular Links

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