I have store configured the same as is in documentation: https://rematchjs.bootcss.com/docs/plugins/loading/, it is:
export type Store = typeof store
export type Dispatch = RematchDispatch<RootModel>
export type RootState = RematchRootState<RootModel, FullModel>
model which is created:
const user = createModel()({...})
Then i cannot use selectors inside a model->effects, because of error


getUserId selector:
export const getUserId = (state: RootState) => getUserData(state).id;
Error says loading is missing. Error doesn't exist if i type RootState without ExtraModels like inside EFFECTS:
export type RootState = RematchRootState<RootModel>, but this is not true (i have extra plugin -> loading)
I think createModel should accept type not only RootModel, but also FullModel, it will satisfy state (seconds parameter) from model effect.
I mean this:
effect:{
myMethod: (payload, state <--THIS ONE){
const sth = mySelector(state); // <-- not working, state is not satisfied, mySelector need RootState, but state here is equal to RematchRootState<RootModel, Record<string, never>>.
State should be typed as RematchRootState<RootModel, FullMode> probably
}
}
To Reproduce
- Create store with LOADING plugin
- Create example model and example selector (like const mySelector = (state:RootState) => sth.
- Try tu use selector inside model effect.