Search
 
SCRIPT & CODE EXAMPLE
 

JAVASCRIPT

useRoutes exact path match in react

import {Outlet, useRoutes} from "react-router-dom"
    
    const App = () => {

      let routeElement = useRoutes([
        {
          path: "/",
          element: <GlobalPageTemplate />,
          children: [
            {
              path: "users",
              element: <Outlet />,
              children: [
                { path: "/", element:<h1>LIST USERS <h1/> },
                {
                  path: "/:id",
                  children: [
                    { path: "/", element: <h1>USER ID</h1> },
                    { path: "/settings", element: <h1>USER SETTINGS</h1> },
                  ],
                },
              ],
            },
            {
              path: "posts",
              element: <Outlet />,
              children: [
                { path: "/", element: <h1>LIST POSTS</h1> },
                {
                  path: "/:id",
                  children: [
                    { path: "/", element: <h1>POST ID</h1> },
                    { path: "/settings", element: <h1>POST SETTINGS</h1> },
                  ],
                },
              ],
            },
            {
              path: "teams",
              element: <Outlet />,
              children: [
                { path: "/", element: <h1>LIST TEAMS</h1> },
                {
                  path: "/:id",
                  children: [
                    { path: "/", element: <h1>TEAMS ID</h1> },
                    { path: "/settings", element: <h1>TEAM SETTINGS</h1> },
                  ],
                },
              ],
            },
          ]
        }
      ]);
    
      return routeElement
    }
Comment

PREVIOUS NEXT
Code Example
Javascript :: javascript delete cookie 
Javascript :: javascript not null 
Javascript :: hello world expressjs 
Javascript :: run javascript from uri 
Javascript :: sum of positive javascript 
Javascript :: get ng content element angular 2 
Javascript :: javascript timestamp in seconds 
Javascript :: jquery class list 
Javascript :: send a message to a specific channel discord.js 
Javascript :: alert confirm prompt javascript 
Javascript :: asyncstorage.getallkeys 
Javascript :: fetch request to GraphQL 
Javascript :: how to call create react app 
Javascript :: empty textarea using jquery 
Javascript :: allow only letters javascript 
Javascript :: js query string 
Javascript :: ajax request 
Javascript :: js array into object 
Javascript :: initialize json array 
Javascript :: javascript remove multiple items from array 
Javascript :: add font awesome to vue 
Javascript :: javascript date today dd mm yyyy 
Javascript :: kubectl get pod by node 
Javascript :: discord.js channel regex 
Javascript :: datatables typeerror k is undefined 
Javascript :: jquery array merge 
Javascript :: eslint disable react 
Javascript :: moment string to date convert node js 
Javascript :: javvascript convert boolean to string 
Javascript :: external button to fire dropzone.js 
ADD CONTENT
Topic
Content
Source link
Name
4+8 =