Hi @mjrussell , I'm using your package in my project and I stumble on this issue where it creates an infinite loop between the new and old url.
For example:
I have a component, ProductDetailComponent with the acceptable Route url
'/product-detail/:id'
I wrapped the component with UserIsAuthenticated
import { UserAuthWrapper } from 'redux-auth-wrapper';
import { routerActions } from 'react-router-redux';
export const UserIsAuthenticated = UserAuthWrapper({
authSelector: (state) => { return state.authentication; },
redirectAction: routerActions.replace,
wrapperDisplayName: 'UserIsAuthenticated',
failureRedirectPath: '/authentication',
predicate: (user) => { return user.accessKey; }
});
At the first load, I go to /product-detail/1
url, and since the User is not authenticated yet, so I got redirected to /authentication
to do the login, and upon successful login, I got redirected again to the original page, /product-detail/1
. So far so good.
Now let's say, in the ProductDetailComponent, there's a selectbox to select similar Product. If the user select another similar product, then the app will trigger an action that will 'restart' the component:
export function restartModule(productId) {
return (dispatch) => {
dispatch(push('/product-detail' + productId));
dispatch(resetSettings());
dispatch(fetchProductDetail(productId));
};
}
And that's when the infinite loop happened.
I tried to debug it but I didn't get far enough. However, if I commented
dispatch(push('/product-detail' + productId));
the infinite loop didn't happen and application works fine (except the url is still the same, doesn't change to the new productId url).
From my understanding, from the Route configuration, regardless which url that I access:
/product-detail/1
/product-detail/2
/product-detail/3
the app will always mount ProductDetailComponent because they match its url pattern /product-detail/:id
, and UserIsAuthenticated should be checked only once, since we are not changing component. So why does the UserIsAuthenticated for ProductDetailComponent get triggered again if push to /product-detail/2
or so on?
Other information, I use react-redux-starter-kit
with:
"react": "^15.0.0",
"react-dom": "^15.0.0",
"react-redux": "^4.0.0",
"react-router": "^2.2.0",
"react-router-redux": "^4.0.0",
"redux": "^3.0.0",
"redux-auth-wrapper": "^0.5.0",
Any pointers to fix this issue? Thanks in advance!