'How to type properties in merging object for getInitialState of createEntityAdapter object?
I want to type status with FetchingStatus type. How to implement that?
type FetchingStatus = 'idle' | 'loading' | 'succeeded' | 'failed';
const initialState = companyPagesAdapter.getInitialState({
status: 'idle',
perPage: 1,
lastPage: 1
});
here is signature of getInitialState:
getInitialState<S extends object>(state: S): EntityState<T> & S
Solution 1:[1]
type FetchingStatus = "idle" | "loading" | "succeeded" | "failed";
interface ExtendedEntityAdapterState {
status: FetchingStatus
perPage: number,
lastPage: number
}
const initialState: ExtendedEntityAdapterState = {
status: 'idle',
perPage: 1,
lastPage: 1
});
companyPagesAdapter.getInitialState(initialState)
Something like this worked for me. Reducer action gives correct constraints.
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
Solution | Source |
---|---|
Solution 1 |