Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

172
Views
React-Router "Link" changes url, but won't trigger render of component

I've torn this example down to barebones to make it as simple as possible.

I have a HomePage with a Link to PostPage

The Link in HomePage wraps a Post component that just says "post" (was originally a list)

CodeSandbox

I've looked up more than a few similar questions and somehow none of them seem to help.

Using react-router-dom: ^5.3.0

App.js

import './App.css';
import { Router, Switch, Route } from 'react-router-dom'
import history from './history'

import HomePage from './pages/HomePage'
import PostPage from './pages/PostPage'

function App() {
  return (
    <div className="App">
      <Router history={history}>
        <Switch>
          <Route path='/' exact component={HomePage} />
          <Route path='/post' component={PostPage} />
        </Switch>
      </Router>
    </div>
  );
}

export default App;

HomePage

import React from 'react'
import { Link } from 'react-router-dom'
import Post from '../components/Post'

class HomePage extends React.Component {
    render() {
        return (
            <Link to='/post'>
                <Post />
            </Link>
        )
    }
}

export default HomePage

Post

const Post = () => <div>Post component</div>
export default Post

PostPage

const PostPage = () => <div>Post Page</div>
export default PostPage

history

import { createBrowserHistory } from 'history'
export default createBrowserHistory()
about 4 years ago · Juan Pablo Isaza
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!