const authReducer=(state={authData:null,loading:false,error:false},action)=>{
switch (action.type) {
case "AUTH_START":
return {...state,loading:true,error:false}
case "AUTH_SUCCESS":
//also storing the data in local storage
localStorage.setItem("profile",JSON.stringify({...action?.data}))
return {...state,loading:false,authData:action.data}
case "AUTH_FAILED":
return {...state,error:true,loading:false}
default:
return state
}
}
export default authReducer
Action File
Reducer Files
Auth.jsx
Kindly help I am struggling with this from 2 days