@samitouri / QOS-React-2 / commits / 8e35b50608

[Transition Tracing] Refactor Code to Remove OffscreeInstance TODOs (#24855)

Refactored code to pass flow and remove TODOs introduced in #24846

Luna Ruan committed Jul 6, 2022 at 09:38 UTC 8e35b5060875c875f468878f94bc3c0d7d45c52d
2 files changed +28 -60
packages/react-reconciler/src/ReactFiberCommitWork.new.js
+14 -30
@@ -2923,34 +2923,21 @@ function commitPassiveMountOnFiber(
2923 if (queue !== null) {
2924 if (isFallback) {
2925 const transitions = queue.transitions;
2926 - let prevTransitions = instance.transitions;
2927 - if (instance.pendingMarkers === null) {
2928 - instance.pendingMarkers = new Set();
2929 - }
2930 - if (transitions !== null && prevTransitions === null) {
2931 - instance.transitions = prevTransitions = new Set();
2932 - }
2933 -
2926 if (transitions !== null) {
2927 transitions.forEach(transition => {
2928 // Add all the transitions saved in the update queue during
2929 // the render phase (ie the transitions associated with this boundary)
2930 // into the transitions set.
2939 - if (prevTransitions === null) {
2940 - // TODO: What if prevTransitions is null?
2941 - } else {
2942 - prevTransitions.add(transition);
2931 + if (instance.transitions === null) {
2932 + instance.transitions = new Set();
2933 }
2934 + instance.transitions.add(transition);
2935 });
2936 }
2937
2938 const markerInstances = queue.markerInstances;
2939 if (markerInstances !== null) {
2940 markerInstances.forEach(markerInstance => {
2950 - if (markerInstance.pendingSuspenseBoundaries === null) {
2951 - markerInstance.pendingSuspenseBoundaries = new Map();
2952 - }
2953 -
2941 const markerTransitions = markerInstance.transitions;
2942 // There should only be a few tracing marker transitions because
2943 // they should be only associated with the transition that
@@ -2958,21 +2945,18 @@ function commitPassiveMountOnFiber(
2945 if (markerTransitions !== null) {
2946 markerTransitions.forEach(transition => {
2947 if (instance.transitions === null) {
2961 - // TODO: What if instance.transitions is null?
2962 - } else {
2963 - if (instance.transitions.has(transition)) {
2964 - if (
2965 - instance.pendingMarkers === null ||
2966 - markerInstance.pendingSuspenseBoundaries === null
2967 - ) {
2968 - // TODO: What if instance.pendingMarkers is null?
2969 - // TODO: What if markerInstance.pendingSuspenseBoundaries is null?
2970 - } else {
2971 - instance.pendingMarkers.add(
2972 - markerInstance.pendingSuspenseBoundaries,
2973 - );
2974 - }
2948 + instance.transitions = new Set();
2949 + } else if (instance.transitions.has(transition)) {
2950 + if (markerInstance.pendingSuspenseBoundaries === null) {
2951 + markerInstance.pendingSuspenseBoundaries = new Map();
2952 + }
2953 + if (instance.pendingMarkers === null) {
2954 + instance.pendingMarkers = new Set();
2955 }
2956 +
2957 + instance.pendingMarkers.add(
2958 + markerInstance.pendingSuspenseBoundaries,
2959 + );
2960 }
2961 });
2962 }
packages/react-reconciler/src/ReactFiberCommitWork.old.js
+14 -30
@@ -2878,34 +2878,21 @@ function commitPassiveMountOnFiber(
2878 if (queue !== null) {
2879 if (isFallback) {
2880 const transitions = queue.transitions;
2881 - let prevTransitions = instance.transitions;
2882 - if (instance.pendingMarkers === null) {
2883 - instance.pendingMarkers = new Set();
2884 - }
2885 - if (transitions !== null && prevTransitions === null) {
2886 - instance.transitions = prevTransitions = new Set();
2887 - }
2888 -
2881 if (transitions !== null) {
2882 transitions.forEach(transition => {
2883 // Add all the transitions saved in the update queue during
2884 // the render phase (ie the transitions associated with this boundary)
2885 // into the transitions set.
2894 - if (prevTransitions === null) {
2895 - // TODO: What if prevTransitions is null?
2896 - } else {
2897 - prevTransitions.add(transition);
2886 + if (instance.transitions === null) {
2887 + instance.transitions = new Set();
2888 }
2889 + instance.transitions.add(transition);
2890 });
2891 }
2892
2893 const markerInstances = queue.markerInstances;
2894 if (markerInstances !== null) {
2895 markerInstances.forEach(markerInstance => {
2905 - if (markerInstance.pendingSuspenseBoundaries === null) {
2906 - markerInstance.pendingSuspenseBoundaries = new Map();
2907 - }
2908 -
2896 const markerTransitions = markerInstance.transitions;
2897 // There should only be a few tracing marker transitions because
2898 // they should be only associated with the transition that
@@ -2913,21 +2900,18 @@ function commitPassiveMountOnFiber(
2900 if (markerTransitions !== null) {
2901 markerTransitions.forEach(transition => {
2902 if (instance.transitions === null) {
2916 - // TODO: What if instance.transitions is null?
2917 - } else {
2918 - if (instance.transitions.has(transition)) {
2919 - if (
2920 - instance.pendingMarkers === null ||
2921 - markerInstance.pendingSuspenseBoundaries === null
2922 - ) {
2923 - // TODO: What if instance.pendingMarkers is null?
2924 - // TODO: What if markerInstance.pendingSuspenseBoundaries is null?
2925 - } else {
2926 - instance.pendingMarkers.add(
2927 - markerInstance.pendingSuspenseBoundaries,
2928 - );
2929 - }
2903 + instance.transitions = new Set();
2904 + } else if (instance.transitions.has(transition)) {
2905 + if (markerInstance.pendingSuspenseBoundaries === null) {
2906 + markerInstance.pendingSuspenseBoundaries = new Map();
2907 + }
2908 + if (instance.pendingMarkers === null) {
2909 + instance.pendingMarkers = new Set();
2910 }
2911 +
2912 + instance.pendingMarkers.add(
2913 + markerInstance.pendingSuspenseBoundaries,
2914 + );
2915 }
2916 });
2917 }