I am working on react native app. I am storing accesstoken in store after login. In every api call i have to pass this token as a header, but token has some expiry. So i have written one Apihandler class to refresh token. But here problem is i don't know how to access redux store in custom class. In react components using connect i can do mapStateToProps and dispatchProps. Please guide me to access store in custom javascript class.
Code:
import { store } from '../Store'
export default class ApiHandler {
static instance = null;
static createInstance() {
var object = new ApiHandler();
return object;
}
static getInstance() {
if (!ApiHandler.instance) {
ApiHandler.instance = ApiHandler.createInstance();
}
return ApiHandler.instance;
}
callApi(){
var token = store.getState().token (not working)
}
}