-
Notifications
You must be signed in to change notification settings - Fork 4.1k
Closed
Description
Issue
amp-state's ability to trigger setState from a [src] binding causes a possible cycle:
<amp-state id="myState" [src]="'/myEndpoint?foo=' + myState.foo"></amp-state>
If the /myEndpoint?foo= XHR returns {foo: <random number>}, then the XHRs will trigger incessantly: [src] mutation -> setState -> [src] mutation
Should only be an issue with amp-state since it's essential behavior is updating the state. Hitherto, no element calls setState via a bind mutation.
A few possible solutions
- Remove
[src]binding for amp-state, instead use forms as described in amp-bind: Support e-commerce XHR use case #8648 (comment). - Change amp-state[src] XHR to only update state and not apply bindings, instead force use of a separate action
myAmpState.refresh. - State change due to
amp-state[src]will ignore mutations toamp-stateelements.
Props to @kmh287 for pointing this out!
Reactions are currently unavailable