react-hybrid icon indicating copy to clipboard operation
react-hybrid copied to clipboard

Error: Could not resolve '[object Object]' from state X

Open anastasiagryshchenko opened this issue 5 years ago • 3 comments

While working with future states we are consistently seeing an issue when first try to redirect to the view in a future state (e.g. with a $state.go) results in no redirect and an error stack trace provided bellow. However, the second try always results in successful redirect. Network tab also shows that the module is being successfully loaded on the first try.

Using a direct url of the state in an anchor's tag href seems to be the workaround, but I was wondering if this was something that could be fixed by either changing the way we work with the react-hybrid or by changing library code.

I was going through the logic and got to this point Screenshot 2020-01-18 at 01 05 24

on the second try definition is present

I would really appreciate help with this and let me know if there is anything I could do to help investigate this better. Thanks!

angular.js:13424 Error: Could not resolve '[object Object]' from state 'app.project' at new Transition (webpack:///./node_modules/@uirouter/core/lib-esm/transition/transition.js?:79:19) at TransitionService.create (webpack:///./node_modules/@uirouter/core/lib-esm/transition/transitionService.js?:174:16) at Transition.redirect (webpack:///./node_modules/@uirouter/core/lib-esm/transition/transition.js?:492:59) at eval (webpack:///./node_modules/@uirouter/core/lib-esm/state/stateService.js?:370:42) at processQueue (webpack:///./node_modules/angular/angular.js?:15757:28) at eval (webpack:///./node_modules/angular/angular.js?:15773:27) at Scope.$eval (webpack:///./node_modules/angular/angular.js?:17025:28) at Scope.$digest (webpack:///./node_modules/angular/angular.js?:16841:31) at eval (webpack:///./node_modules/angular/angular.js?:17064:26) at completeOutstandingRequest (webpack:///./node_modules/angular/angular.js?:5824:10

anastasiagryshchenko avatar Jan 17 '20 23:01 anastasiagryshchenko

@anastasiagryshchenko in the screenshot, it looks like the transition has a "relative" value of app.foo but is trying to transition to app.foo.**, is this correct?

What other details can you provide? Is this a pure $state.go() call you're making imperatively? Or from a UISref?

christopherthielen avatar Feb 05 '20 03:02 christopherthielen

behavior is the same for both $state.go and UISref navigation.

the first transition is trying to resolve future state instead of the specific one and fails, we can observe the module load, and then the next time user tries to navigate to smth (e.g.click on the link with ui-sref) everything works correctly.

anastasiagryshchenko avatar Feb 10 '20 19:02 anastasiagryshchenko

This is surprising. Especially the result of targetState.name() being { url: "/deployments", name: "app.deployments.**", $$state: f }. The logic found in name() should have returned app.deployments.**:

  /** The name of the state this object targets */
  name(): string {
    return (this._definition && this._definition.name) || <string>this._identifier;
  }

Can you provide the following additional info:

Output of:

  • npm ls @uirouter/angular-hybrid
  • npm ls @uirouter/core
  • npm ls @uirouter/angular
  • npm ls @uirouter/angularjs

What is in targetState._identifier?

As long as you're stepping through ui-router code, can you step through TargetState constructor, specifically this line https://github.com/ui-router/core/blob/e657cfef2a36be136456710974f8b3078d57e697/src/state/targetState.ts#L74

This should be finding the futurestate StateObject from the StateRegistry that matches the glob app.deployments.**. However, since _definition is empty, it must not have been found.

christopherthielen avatar Apr 20 '20 01:04 christopherthielen