如何导出Redux状态字段?



得到这个错误:

Property 'authnUser' does not exist on type 'TypedUseSelectorHook<RootState>'.

我试着这样导出:

export const authnUser = (state: TypedUseSelectorHook<RootState>) =>
state.authnUser

我有以下声明:

interface RootState {
authnResp: AuthnRes
soldTickets: SoldTicketRes
}
const initialState: RootState = {
authnResp: null,
soldTickets: null,
}
const tikexAPI = createSlice({
name: 'authnUser',
initialState,
reducers: {
setAuthnRes(state, action: PayloadAction<AuthnRes | null>) {
state.authnResp = action.payload
},
},

应该是

export const authnUser = (state: RootState) =>
state.authnUser

最新更新