I want fetch some state from my store in one of the utils functions that I have. I know that I can do something like that:
import { store } from '../Store';
const func() {
const state = store.getState()
}
Now, this gives me access to the whole store furthermore, when I try to access the elements in my store I don't get autocompletion like I get when I use useSelector hook.
I wanted to know if there's anyway that I can actually get autocompletion or get access to only something specific when I access the store outside a component.
Maybe something like this: (I know it doesn't work, but I just want to know if there' something like this that I can do)
store<SomeTypeInMyStore>.getState()
This how my store is constructed:
const persistConfig :any = {
key: 'root',
storage: AsyncStorage,
whitelist: ['login', 'biometrics']
};
const persistedReducer = persistReducer(persistConfig, reducers);
const store: Store<any> = createStore(
persistedReducer,
applyMiddleware(thunk)
);
const persistor = persistStore(store);
export { store, persistor };
useSelectororuseStore.