(
existingChildren: Map<string | number, Fiber>,
returnFiber: Fiber,
newIdx: number,
newChild: any,
lanes: Lanes,
)
| 939 | } |
| 940 | |
| 941 | function updateFromMap( |
| 942 | existingChildren: Map<string | number, Fiber>, |
| 943 | returnFiber: Fiber, |
| 944 | newIdx: number, |
| 945 | newChild: any, |
| 946 | lanes: Lanes, |
| 947 | ): Fiber | null { |
| 948 | if ( |
| 949 | (typeof newChild === 'string' && newChild !== '') || |
| 950 | typeof newChild === 'number' || |
| 951 | typeof newChild === 'bigint' |
| 952 | ) { |
| 953 | // Text nodes don't have keys, so we neither have to check the old nor |
| 954 | // new node for the key. If both are text nodes, they match. |
| 955 | const matchedFiber = existingChildren.get(newIdx) || null; |
| 956 | return updateTextNode( |
| 957 | returnFiber, |
| 958 | matchedFiber, |
| 959 | // $FlowFixMe[unsafe-addition] Flow doesn't want us to use `+` operator with string and bigint |
| 960 | '' + newChild, |
| 961 | lanes, |
| 962 | ); |
| 963 | } |
| 964 | |
| 965 | if (typeof newChild === 'object' && newChild !== null) { |
| 966 | switch (newChild.$$typeof) { |
| 967 | case REACT_ELEMENT_TYPE: { |
| 968 | const matchedFiber = |
| 969 | existingChildren.get( |
| 970 | newChild.key === null ? newIdx : newChild.key, |
| 971 | ) || null; |
| 972 | const prevDebugInfo = pushDebugInfo(newChild._debugInfo); |
| 973 | const updated = updateElement( |
| 974 | returnFiber, |
| 975 | matchedFiber, |
| 976 | newChild, |
| 977 | lanes, |
| 978 | ); |
| 979 | currentDebugInfo = prevDebugInfo; |
| 980 | return updated; |
| 981 | } |
| 982 | case REACT_PORTAL_TYPE: { |
| 983 | const matchedFiber = |
| 984 | existingChildren.get( |
| 985 | newChild.key === null ? newIdx : newChild.key, |
| 986 | ) || null; |
| 987 | return updatePortal(returnFiber, matchedFiber, newChild, lanes); |
| 988 | } |
| 989 | case REACT_LAZY_TYPE: { |
| 990 | const prevDebugInfo = pushDebugInfo(newChild._debugInfo); |
| 991 | const resolvedChild = resolveLazy((newChild: any)); |
| 992 | const updated = updateFromMap( |
| 993 | existingChildren, |
| 994 | returnFiber, |
| 995 | newIdx, |
| 996 | resolvedChild, |
| 997 | lanes, |
| 998 | ); |
no test coverage detected