1

Whether it's using this.props.history.push or <Link to={}> the component won't rerender if it's already at the same url.

Sometime in my container there will be logic that render different pieces, I don't want to use window.location.reload() to hard refresh the entire thing.

Melissa93
  • 111
  • 2
  • 4

2 Answers2

0

This is what I did and its working.

<Route path='/get-random-poll' exact>
        <Redirect
             to={{
                  pathname: 'polls',
                  state: {
                     randomPoll: true
                  }
             }}
       />
</Route>

I make a route /get-random-poll that has nothing but redirect to the /polls. So when you are on /polls, router goes /get-random-poll and it redirects to /polls

-1

You can use history.pushState or history.replaceState. They should do the trick.

About the difference between them: https://stackoverflow.com/a/17507140/5709697

Prashant Pimpale
  • 10,349
  • 9
  • 44
  • 84
Azamat Zorkanov
  • 779
  • 1
  • 4
  • 9
  • what is the different btw `this.props.history.push` vs `history.pushState`? My question is about react-router not browser API. – Melissa93 Jul 23 '18 at 00:32