,errorElement: I'm using Reactjs and I'm trying to use "Dynamic Routing" now, but the page appears blank. This is my routing file: I'm trying to access the "User.js" file in (src/pages), this is my User.js file:export default function Router() { return useRoutes([ { path: "/", element:
import React, { useEffect, useState } from "react"; import { useParams, withRouter } from "react-router"; import axios from "axios"; const User = (props) => { const params = useParams(); const [users, setUsers] = useState({}); useEffect(() => { async function fetchData() { const res = await axios( `https://jsonplaceholder.typicode.com/comments/${params.id}` ); console.log("INDI", res.data); setUsers(res.data); } fetchData(); }, []); return ( <>
The problem is that you added
index=true
to both child elements. You can only have one index pageExample:
You can learn more about the purpose ofindex=truefrom the
accepted answer
to this question.