skip to Main Content

I’m trying to learn react navigation, using route and route path but I seem to be making mistake somewhere, can anyone help me with it?

I tried to keep changing the div and the div that shows the posts but it doesn’t show anything now, it was showing the posts and the buttons but couldn’t go to Profile.js
Here’s the code from App.js for the function App :

function App() {
  const [posts, setPosts] = useState([]);

  usePostList(setPosts);

  return (
    <div className="App">
      <div className="container">
        {_renderJumbotron}
        {_renderCard(posts)}
      </div>
            
      <Routes>
        <Route path="/profile" Component={<Profile/>} />
      </Routes>
    </div>
  );
}

export default App;

2

Answers


  1. You need to change the Component to element

    <Routes>
            <Route path="/profile" element={<Profile/>} />
    </Routes>
    
    Login or Signup to reply.
  2. Instead of component you should use element

    <Routes>
        <Route path="/profile" element={<Profile/>} />
    
    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search