You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I would like to be able to redirect dynamically based on state. However, the Redirect component only performs the redirect in componentDidMount and not from within componentDidUpdate. This restriction seems rather artificial and to me feels counterintuitive.
My use case is as follows: An infinite scrolling list that updates the currently active page index in the location state. Some stripped-down example code:
constInfiniteList=({ match, startIndex, rows, setStartIndex })=><div><InfiniteScrollrows={rows}loadMoreRows={setStartIndex}/><Redirectkey={index}to={`${match.url}/${startIndex}`}/></div>exportdefaultcompose(withState('startIndex','setStartIndex',({ match })=>match.params.index||0))(InfiniteList)
Note the key={index} prop on the Redirect element. This is my workaround for triggering componentDidMount again after every page switch. I would prefer if the redirect would just work™ without this hack.
The text was updated successfully, but these errors were encountered:
I would like to be able to redirect dynamically based on state. However, the
Redirect
component only performs the redirect incomponentDidMount
and not from withincomponentDidUpdate
. This restriction seems rather artificial and to me feels counterintuitive.My use case is as follows: An infinite scrolling list that updates the currently active page index in the location state. Some stripped-down example code:
Note the
key={index}
prop on theRedirect
element. This is my workaround for triggeringcomponentDidMount
again after every page switch. I would prefer if the redirect would just work™ without this hack.The text was updated successfully, but these errors were encountered: