MCPcopy Index your code
hub / github.com/plotly/dash / mapIntoArray

Function mapIntoArray

dash/deps/react@18.2.0.js:1008–1125  ·  view source on GitHub ↗
(children, array, escapedPrefix, nameSoFar, callback)

Source from the content-addressed store, hash-verified

1006 }
1007
1008 function mapIntoArray(children, array, escapedPrefix, nameSoFar, callback) {
1009 var type = typeof children;
1010
1011 if (type === 'undefined' || type === 'boolean') {
1012 // All of the above are perceived as null.
1013 children = null;
1014 }
1015
1016 var invokeCallback = false;
1017
1018 if (children === null) {
1019 invokeCallback = true;
1020 } else {
1021 switch (type) {
1022 case 'string':
1023 case 'number':
1024 invokeCallback = true;
1025 break;
1026
1027 case 'object':
1028 switch (children.$$typeof) {
1029 case REACT_ELEMENT_TYPE:
1030 case REACT_PORTAL_TYPE:
1031 invokeCallback = true;
1032 }
1033
1034 }
1035 }
1036
1037 if (invokeCallback) {
1038 var _child = children;
1039 var mappedChild = callback(_child); // If it's the only child, treat the name as if it was wrapped in an array
1040 // so that it's consistent if the number of children grows:
1041
1042 var childKey = nameSoFar === '' ? SEPARATOR + getElementKey(_child, 0) : nameSoFar;
1043
1044 if (isArray(mappedChild)) {
1045 var escapedChildKey = '';
1046
1047 if (childKey != null) {
1048 escapedChildKey = escapeUserProvidedKey(childKey) + '/';
1049 }
1050
1051 mapIntoArray(mappedChild, array, escapedChildKey, '', function (c) {
1052 return c;
1053 });
1054 } else if (mappedChild != null) {
1055 if (isValidElement(mappedChild)) {
1056 {
1057 // The `if` statement here prevents auto-disabling of the safe
1058 // coercion ESLint rule, so we must manually disable it below.
1059 // $FlowFixMe Flow incorrectly thinks React.Portal doesn't have a key
1060 if (mappedChild.key && (!_child || _child.key !== mappedChild.key)) {
1061 checkKeyStringCoercion(mappedChild.key);
1062 }
1063 }
1064
1065 mappedChild = cloneAndReplaceKey(mappedChild, // Keep both the (mapped) and old keys if they differ, just as

Callers 1

mapChildrenFunction · 0.70

Calls 11

pushMethod · 0.80
keysMethod · 0.80
getElementKeyFunction · 0.70
isArrayFunction · 0.70
escapeUserProvidedKeyFunction · 0.70
isValidElementFunction · 0.70
checkKeyStringCoercionFunction · 0.70
cloneAndReplaceKeyFunction · 0.70
getIteratorFnFunction · 0.70
warnFunction · 0.70
callbackFunction · 0.50

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…