react-relay 0.0.0-main-7b0eeb0d → 0.0.0-main-a0680e86
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/ReactRelayContext.js
CHANGED
package/hooks.js
CHANGED
package/index.js
CHANGED
package/legacy.js
CHANGED
|
@@ -430,14 +430,19 @@ function useFragmentInternal_EXPERIMENTAL(fragmentNode, fragmentRef, hookDisplay
|
|
|
430
430
|
}
|
|
431
431
|
}
|
|
432
432
|
handlePotentialSnapshotErrorsForState(environment, state, loggerContext);
|
|
433
|
-
var storeSubscriptionRef = useRef(
|
|
433
|
+
var storeSubscriptionRef = useRef({
|
|
434
|
+
kind: 'uninitialized'
|
|
435
|
+
});
|
|
434
436
|
useEffect(function () {
|
|
435
437
|
var storeSubscription = storeSubscriptionRef.current;
|
|
436
|
-
if (storeSubscription
|
|
438
|
+
if (storeSubscription.kind === 'initialized') {
|
|
437
439
|
if (state.environment === storeSubscription.environment && state.selector === storeSubscription.selector) {
|
|
438
440
|
return;
|
|
439
441
|
} else {
|
|
440
442
|
storeSubscription.dispose();
|
|
443
|
+
storeSubscriptionRef.current = {
|
|
444
|
+
kind: 'uninitialized'
|
|
445
|
+
};
|
|
441
446
|
}
|
|
442
447
|
}
|
|
443
448
|
if (state.kind === 'bailout') {
|
|
@@ -450,30 +455,38 @@ function useFragmentInternal_EXPERIMENTAL(fragmentNode, fragmentRef, hookDisplay
|
|
|
450
455
|
updatedState = updates[1];
|
|
451
456
|
if (didMissUpdates) {
|
|
452
457
|
setState(updatedState);
|
|
458
|
+
storeSubscriptionRef.current = {
|
|
459
|
+
kind: 'missed-updates'
|
|
460
|
+
};
|
|
453
461
|
return;
|
|
454
462
|
}
|
|
455
463
|
stateForSubscription = updatedState;
|
|
456
464
|
}
|
|
457
465
|
var dispose = subscribeToSnapshot(state.environment, stateForSubscription, setState);
|
|
458
466
|
storeSubscriptionRef.current = {
|
|
467
|
+
kind: 'initialized',
|
|
459
468
|
dispose: dispose,
|
|
460
469
|
selector: state.selector,
|
|
461
470
|
environment: state.environment
|
|
462
471
|
};
|
|
463
472
|
}, [state]);
|
|
464
473
|
useEffect(function () {
|
|
465
|
-
if (storeSubscriptionRef.current
|
|
474
|
+
if (storeSubscriptionRef.current.kind === 'uninitialized' && state.kind !== 'bailout') {
|
|
466
475
|
var dispose = subscribeToSnapshot(state.environment, state, setState);
|
|
467
476
|
storeSubscriptionRef.current = {
|
|
477
|
+
kind: 'initialized',
|
|
468
478
|
dispose: dispose,
|
|
469
479
|
selector: state.selector,
|
|
470
480
|
environment: state.environment
|
|
471
481
|
};
|
|
472
482
|
}
|
|
473
483
|
return function () {
|
|
474
|
-
|
|
475
|
-
|
|
476
|
-
|
|
484
|
+
if (storeSubscriptionRef.current.kind === 'initialized') {
|
|
485
|
+
storeSubscriptionRef.current.dispose();
|
|
486
|
+
}
|
|
487
|
+
storeSubscriptionRef.current = {
|
|
488
|
+
kind: 'uninitialized'
|
|
489
|
+
};
|
|
477
490
|
};
|
|
478
491
|
}, []);
|
|
479
492
|
var data;
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "react-relay",
|
|
3
3
|
"description": "A framework for building GraphQL-driven React applications.",
|
|
4
|
-
"version": "0.0.0-main-
|
|
4
|
+
"version": "0.0.0-main-a0680e86",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"graphql",
|
|
7
7
|
"relay",
|
|
@@ -20,7 +20,7 @@
|
|
|
20
20
|
"fbjs": "^3.0.2",
|
|
21
21
|
"invariant": "^2.2.4",
|
|
22
22
|
"nullthrows": "^1.1.1",
|
|
23
|
-
"relay-runtime": "0.0.0-main-
|
|
23
|
+
"relay-runtime": "0.0.0-main-a0680e86"
|
|
24
24
|
},
|
|
25
25
|
"peerDependencies": {
|
|
26
26
|
"react": "^16.9.0 || ^17 || ^18 || ^19"
|
|
@@ -608,15 +608,20 @@ hook useFragmentInternal_EXPERIMENTAL(
|
|
|
608
608
|
// or detaches (<Activity> going hidden), and then re-subscribes when the component
|
|
609
609
|
// re-attaches (<Activity> going visible). These cases wouldn't fire the
|
|
610
610
|
// "update" effect because the state and environment don't change.
|
|
611
|
-
const storeSubscriptionRef = useRef<
|
|
612
|
-
|
|
613
|
-
|
|
614
|
-
|
|
615
|
-
|
|
611
|
+
const storeSubscriptionRef = useRef<
|
|
612
|
+
| {
|
|
613
|
+
kind: 'initialized',
|
|
614
|
+
dispose: () => void,
|
|
615
|
+
selector: ?ReaderSelector,
|
|
616
|
+
environment: IEnvironment,
|
|
617
|
+
}
|
|
618
|
+
| {kind: 'missed-updates'}
|
|
619
|
+
| {kind: 'uninitialized'},
|
|
620
|
+
>({kind: 'uninitialized'});
|
|
616
621
|
// $FlowFixMe[react-rule-hook] - the condition is static
|
|
617
622
|
useEffect(() => {
|
|
618
623
|
const storeSubscription = storeSubscriptionRef.current;
|
|
619
|
-
if (storeSubscription
|
|
624
|
+
if (storeSubscription.kind === 'initialized') {
|
|
620
625
|
if (
|
|
621
626
|
state.environment === storeSubscription.environment &&
|
|
622
627
|
state.selector === storeSubscription.selector
|
|
@@ -626,6 +631,7 @@ hook useFragmentInternal_EXPERIMENTAL(
|
|
|
626
631
|
} else {
|
|
627
632
|
// The selector has changed, so we need to dispose of the previous subscription
|
|
628
633
|
storeSubscription.dispose();
|
|
634
|
+
storeSubscriptionRef.current = {kind: 'uninitialized'};
|
|
629
635
|
}
|
|
630
636
|
}
|
|
631
637
|
if (state.kind === 'bailout') {
|
|
@@ -650,7 +656,11 @@ hook useFragmentInternal_EXPERIMENTAL(
|
|
|
650
656
|
// to using the latest snapshot to subscribe.
|
|
651
657
|
if (didMissUpdates) {
|
|
652
658
|
setState(updatedState);
|
|
659
|
+
storeSubscriptionRef.current = {kind: 'missed-updates'};
|
|
653
660
|
// We missed updates, we're going to render again anyway so wait until then to subscribe
|
|
661
|
+
// Setting the ref to kind: missed-updates ensures the second useEffect (simulating the
|
|
662
|
+
// setup/teardown part of the crud effect) will not set up the subscription w the stale
|
|
663
|
+
// state
|
|
654
664
|
return;
|
|
655
665
|
}
|
|
656
666
|
stateForSubscription = updatedState;
|
|
@@ -661,6 +671,7 @@ hook useFragmentInternal_EXPERIMENTAL(
|
|
|
661
671
|
setState,
|
|
662
672
|
);
|
|
663
673
|
storeSubscriptionRef.current = {
|
|
674
|
+
kind: 'initialized',
|
|
664
675
|
dispose,
|
|
665
676
|
selector: state.selector,
|
|
666
677
|
environment: state.environment,
|
|
@@ -668,17 +679,23 @@ hook useFragmentInternal_EXPERIMENTAL(
|
|
|
668
679
|
}, [state]);
|
|
669
680
|
// $FlowFixMe[react-rule-hook] - the condition is static
|
|
670
681
|
useEffect(() => {
|
|
671
|
-
if (
|
|
682
|
+
if (
|
|
683
|
+
storeSubscriptionRef.current.kind === 'uninitialized' &&
|
|
684
|
+
state.kind !== 'bailout'
|
|
685
|
+
) {
|
|
672
686
|
const dispose = subscribeToSnapshot(state.environment, state, setState);
|
|
673
687
|
storeSubscriptionRef.current = {
|
|
688
|
+
kind: 'initialized',
|
|
674
689
|
dispose,
|
|
675
690
|
selector: state.selector,
|
|
676
691
|
environment: state.environment,
|
|
677
692
|
};
|
|
678
693
|
}
|
|
679
694
|
return () => {
|
|
680
|
-
storeSubscriptionRef.current
|
|
681
|
-
|
|
695
|
+
if (storeSubscriptionRef.current.kind === 'initialized') {
|
|
696
|
+
storeSubscriptionRef.current.dispose();
|
|
697
|
+
}
|
|
698
|
+
storeSubscriptionRef.current = {kind: 'uninitialized'};
|
|
682
699
|
};
|
|
683
700
|
// NOTE: this intentionally has no dependencies, see above comment about
|
|
684
701
|
// simulating a CRUD effect
|