登录后,我想返回用户对象到切片,但我一直得到一个错误,关于不可序列化的数据,我如何正确配置?
的数据
export const updateProfileAsync = createAsyncThunk('user/updateProfile', async(user:any,
profile:any)=>{
const response = await updateProfile(user,profile)
return response.user
})
字符串
介面
interface userState {
user:User
}
型
在我切片中,
extraReducers:(builder) => {
builder.addCase(loginAsync.pending, (state,action)=>{
console.log('pending')
state.loading = 'pending'
})
builder.addCase(loginAsync.fulfilled, (state,action)=>{
state.loading = 'succeeded'
console.log('logged in')
console.log(action.payload)
state.loginError = ''
})
builder.addCase(loginAsync.rejected, (state,action)=>{
state.loginError = action.error.message
state.loading = 'failed'
console.log('failed')
})
型
1条答案
按热度按时间tvz2xvvm1#
看起来你的对象
user.user
是不可序列化的,但是你返回到切片的数据应该是aserializable。你可以在这里看看如何在Redux中处理不可序列化的数据。
使用React-Redux-Firebase