Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

LOADING_USER called multiple times from my reducers #175

Open
mk0sojo opened this issue Aug 26, 2020 · 0 comments
Open

LOADING_USER called multiple times from my reducers #175

mk0sojo opened this issue Aug 26, 2020 · 0 comments

Comments

@mk0sojo
Copy link

mk0sojo commented Aug 26, 2020

This is kind of related to issue #63

We have an app set up similar to the example app.
The problem we have is the gap between oidcReducer.user is set and storedUser is set in oidcMiddleware.js.
When the oidcReducer.user is populated we will render the App component:

{isLoadingUser || !user || user.expired ? : }

The App component will immediately dispatch three BEGIN_API_CALL actions (for 3 different API calls). This will trigger three LOADING_USER - USER_FOUND action dispatches which (at least in our app) triggers more API calls.

Looking at the code in oidcMiddleware we could solve this by adding "!action.type.startsWith('redux-oidc/')" to the following if statement:

if (
action.type === USER_EXPIRED ||
action.type === LOADING_USER ||
action.type === USER_FOUND ||
!action.type.startsWith('redux-oidc/')
) {
return next(action);
}

I can create a pull request if this seems like a good solution. The other solution could possibly be to set the user when action.type === USER_FOUND?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant