| 1 | // @enableNewMutationAliasingModel |
| 2 | import {CONST_TRUE, Stringify, mutate, useIdentity} from 'shared-runtime'; |
| 3 | |
| 4 | /** |
| 5 | * Fixture showing an edge case for ReactiveScope variable propagation. |
| 6 | * Fixed in the new inference model |
| 7 | * |
| 8 | * Found differences in evaluator results |
| 9 | * Non-forget (expected): |
| 10 | * <div>{"obj":{"inner":{"value":"hello"},"wat0":"joe"},"inner":["[[ cyclic ref *2 ]]"]}</div> |
| 11 | * <div>{"obj":{"inner":{"value":"hello"},"wat0":"joe"},"inner":["[[ cyclic ref *2 ]]"]}</div> |
| 12 | * Forget: |
| 13 | * <div>{"obj":{"inner":{"value":"hello"},"wat0":"joe"},"inner":["[[ cyclic ref *2 ]]"]}</div> |
| 14 | * [[ (exception in render) Error: invariant broken ]] |
| 15 | * |
| 16 | */ |
| 17 | function Component() { |
| 18 | const obj = CONST_TRUE ? {inner: {value: 'hello'}} : null; |
| 19 | const boxedInner = [obj?.inner]; |
| 20 | useIdentity(null); |
| 21 | mutate(obj); |
| 22 | if (boxedInner[0] !== obj?.inner) { |
| 23 | throw new Error('invariant broken'); |
| 24 | } |
| 25 | return <Stringify obj={obj} inner={boxedInner} />; |
| 26 | } |
| 27 | |
| 28 | export const FIXTURE_ENTRYPOINT = { |
| 29 | fn: Component, |
| 30 | params: [{arg: 0}], |
| 31 | sequentialRenders: [{arg: 0}, {arg: 1}], |
| 32 | }; |