Closed Sean-Brown-Digi closed 5 years ago
Figured it out right after posting this... just got to call toString()
on the action type:
import actions from './actions';
export default (state = '', action: any) => {
switch (action.type.toString()) {
case getType(actions.request):
return state;
case getType(actions.success):
return state;
case getType(actions.failure):
return state;
default:
console.log(`unknown action`, action);
return state;
}
}
I created some async actions:
In the reducer I'm trying to switch based on the action type , however I can't seem to get the switch statement correct, maybe you could help?
I tried the switch statement both with and without the
.name
property and it always goes to the default case. When debugging I noticed that the.name
property is always an empty string, which is surprising to me because that property saysReturns the name of the function. Function names are read-only and can not be changed.
.How can I get the switch statement to work using the object produced by
CreateAsyncActions()
?