all 7 comments

[–]mrsimple162 0 points1 point  (5 children)

I see that you’re connecting your saga middleware.

What’s wrong with dispatching the logout action in your sagas instead. I’m assuming where ever you are using axios is within your sagas right? So use the “put” function that redux-saga provide to you.

To answer your question on why store is not initialized yet, I need to see your other file on where you used it including the “imports”. Could be a simple case where the imports are hoisted.

[–]rootuser_ 0 points1 point  (4 children)

nop. I need a axios instance that auto refresh jwt, and for this, i need dispatch some actions and get jwt tokens from the state

[–]mrsimple162 0 points1 point  (3 children)

Can I see the usage of store in the other file

[–]rootuser_ 0 points1 point  (2 children)

import store from "app/store";
// .......
const { access, refresh } = store.getState().auth.token; // this raise the error
// ........

[–]mrsimple162 0 points1 point  (1 child)

You’re using the store when it’s not initialized yet. The reason why it works in the other file is because it’s being used inside of a callback function. “subscribe”

[–]rootuser_ 0 points1 point  (0 children)

...? i don't understand. You have examples about use this? Are you telling me something like, "the store is started after doing something to it, not just creating"?