I have this function in
export const authSlice = createSlice({
name: "auth",
initialState: {
credentials: {},
isLoading: false,
},
reducers: {
isLoading: (state) => {
state.isLoading = !state.isLoading;
},
},
extraReducers: (builder) => {
builder
.addCase(signInByEmail.fulfilled, (state, action) => {
state.credentials = action.payload;
})
.addCase(signInByEmail.rejected, (state, action) => {
Alert.alert(
"OOPS!",
"Wrong Email or Password",
[{ text: "Try Again" }],
{ cancelable: false }
);
})
.addCase(signUpByEmail.pending, state => state.isLoading = true)
.addCase(signUpByEmail.fulfilled, (state, action)=> {
})
},
});
its Giving me an error in state.isLoading = true
But if i do it like this
export const authSlice = createSlice({
name: "auth",
initialState: {
credentials: {},
isLoading: false,
},
reducers: {
isLoading: (state) => {
state.isLoading = !state.isLoading;
},
},
extraReducers: (builder) => {
builder
.addCase(signInByEmail.fulfilled, (state, action) => {
state.credentials = action.payload;
})
.addCase(signInByEmail.rejected, (state, action) => {
Alert.alert(
"OOPS!",
"Wrong Email or Password",
[{ text: "Try Again" }],
{ cancelable: false }
);
})
.addCase(signUpByEmail.pending, (state, action) => {
state.isLoading = true
})
.addCase(signUpByEmail.fulfilled, (state, action)=> {
})
},
});
After i broke into another line i get no error. What an I missing.
This is the error im getting just in case.
No overload matches this call. Overload 1 of 2, '(actionCreator: AsyncThunkPendingActionCreator<{ email: string; password: string; }>, reducer: CaseReducer<{ credentials: {}; isLoading: boolean; }, PayloadAction<undefined, string, { ...; }, never>>): ActionReducerMapBuilder<...>', gave the following error. Type 'boolean' is not assignable to type 'void | { credentials: {}; isLoading: boolean; }'. Overload 2 of 2, '(type: string, reducer: CaseReducer<{ credentials: {}; isLoading: boolean; }, Action>):