React Router v4 - onEnter

(Imbr) #1

I would like to fetch data from the API after EVERY call of (redux LOCATION_CHANGE acction).

  <Route path="/some"/>
  <Route ... />

In older versions of <Route>, we could use the onEnter event to set some promises which retrieved the data.
How to correctly/professionally do it now?

For the moment I have set REDUX SAGA listener for every LOCATION_CHANGE acction. But this solution limits me.

I will be grateful for your help :slight_smile:

(Ihtml5) #2

@imbr you can fetch data in Route render function

(Imbr) #3

Thank you for your answer,
Could you show me some basic example?

(Ihtml5) #4


  <Route path="/some" render={({match, location, history} ) => {
  <Route ... />