Trying to create an about page for a website im working on, I found this solution on Stack but it does not work for me. I was using an outdated tutorial for my original code, this is my current code:
About.js:
import React from "react"; import { Link, Route, useMatch } from "react-router-dom"; import SinglePage from "./SinglePage"; const About = () => { //const match = useMatch('/'); return ( <div className="about__content"> <ul className="about__list"> <li> <Link to={'about-app'}>About App</Link> </li> <li> <Link to={'about-author'}>About Author</Link> </li> </ul> <Route path={':slug'}> <SinglePage /> </Route> </div> ); }; export default About; Index.js where I am rendering the component:
import React from "react"; import ReactDOM from "react-dom"; import TodoContainer from "./functionBased/components/TodoContainer"; // Component file import "./functionBased/App.css"; // Style sheet import { HashRouter as Router, Routes, Route } from "react-router-dom"; // Router file import About from "./functionBased/pages/About"; import NotMatch from "./functionBased/pages/NotMatch"; ReactDOM.render( <React.StrictMode> <Router> <Routes> <Route exact path="/" element={<TodoContainer />} /> <Route path="/about/*" element={<About />} /> <Route path="*" element={<NotMatch />} /> </Routes> </Router> </React.StrictMode>, document.getElementById("root") );