Promise - react - accessories - Unable to send promises as route accessories


In the below code if the first call fails and the second call returns response, the cp value updated inside catch block is not available as props. The cp has the error which was the response of first call. I need the response of second call to be available in my component

cp = getcp() // getcp returns promises
  cp.catch(ex => {
   if (ex) {
   cp = getcp()
   cp.catch(ex => {
    cp = {}
  } else {
    cp = {}

I am sending the cp value in route as <Route path={ PAGE } component={ component } onEnter={ refresh } cp={ cp }/> and in component I am taking it has this.props.route.cp

If the first call is success the cp is properly passed. this.props.route.cp in the chid component returns the cp value. This actually fails only on second call

I guess custom props is no longer work in react-router v4. You might want to prepare a function that returns your component like below.

const PassComponent = (props) => {
    return (

And call it this way

Route path={ PAGE } component={ PassComponent } onEnter={ refresh } />

Reference :