Closed richarddavenport closed 7 years ago
I'm seeing what looks like the same issue in an Ionic 3 project, with the following versions:
├─ @ngrx/core@1.2.0
├─ @ngrx/effects@2.0.3
├─ @ngrx/store-devtools@3.2.4
├─ @ngrx/store@2.2.2
Stack trace:
core.es5.js:1084 ERROR Error: Uncaught (in promise): TypeError: Cannot read property 'type' of undefined
TypeError: Cannot read property 'type' of undefined
at Object.performAction (actions.js:17)
at MapSubscriber.liftAction [as project] (utils.js:20)
at MapSubscriber._next (map.js:77)
at MapSubscriber.Subscriber.next (Subscriber.js:89)
at MergeAllSubscriber.OuterSubscriber.notifyNext (OuterSubscriber.js:19)
at InnerSubscriber._next (InnerSubscriber.js:23)
at InnerSubscriber.Subscriber.next (Subscriber.js:89)
at SkipSubscriber._next (skip.js:46)
at SkipSubscriber.Subscriber.next (Subscriber.js:89)
at Dispatcher.Subject.next (Subject.js:55)
at Object.performAction (actions.js:17)
at MapSubscriber.liftAction [as project] (utils.js:20)
at MapSubscriber._next (map.js:77)
at MapSubscriber.Subscriber.next (Subscriber.js:89)
at MergeAllSubscriber.OuterSubscriber.notifyNext (OuterSubscriber.js:19)
at InnerSubscriber._next (InnerSubscriber.js:23)
at InnerSubscriber.Subscriber.next (Subscriber.js:89)
at SkipSubscriber._next (skip.js:46)
at SkipSubscriber.Subscriber.next (Subscriber.js:89)
at Dispatcher.Subject.next (Subject.js:55)
at c (polyfills.js:3)
at Object.reject (polyfills.js:3)
at NavControllerBase._fireError (nav-controller-base.js:322)
at NavControllerBase._failed (nav-controller-base.js:310)
at nav-controller-base.js:365
at t.invoke (polyfills.js:3)
at Object.onInvoke (core.es5.js:4125)
at t.invoke (polyfills.js:3)
at r.run (polyfills.js:3)
at polyfills.js:3
Never mind. I was being an idiot. I was using the store to dispatch an action inside one of my effects, instead of just returning the action.
I was doing:
@Effect() userTier$ = this.actions$
.ofType(Actions.REACHED_THRESHOLD)
.map(toPayload)
.mergeMap(reachedThreshold => {
return Observable.of(this.store.dispatch(
reachedThreshold ?
this.actions.setAsTier2User() :
this.actions.setAsTier1User()
));
});
When I should have been doing:
@Effect() userTier$ = this.actions$
.ofType(Actions.REACHED_THRESHOLD)
.map(toPayload)
.mergeMap(reachedThreshold => {
return Observable.of(reachedThreshold ?
this.actions.setAsTier2User() :
this.actions.setAsTier1User()
);
});
Forgot I reported this. That's what I was doing to. I too was an idiot 😀
I should join in the idiot gang as well :)
Not sure why this is happening. I don't have any effects that do not dispatch actions. When
performAction
gets called:I'm not getting the thrown error because
action
is undefined.