| 1136 | class="cm">// Instead they should be attributed to their parent custom hook. |
| 1137 | class="cm">// This method walks the tree and assigns debug values to their custom hook owners. |
| 1138 | function processDebugValues( |
| 1139 | hooksTree: HooksTree, |
| 1140 | parentHooksNode: HooksNode | null, |
| 1141 | ): void { |
| 1142 | const debugValueHooksNodes: Array<HooksNode> = []; |
| 1143 | |
| 1144 | for (let i = 0; i < hooksTree.length; i++) { |
| 1145 | const hooksNode = hooksTree[i]; |
| 1146 | if (hooksNode.name === class="st">'DebugValue' && hooksNode.subHooks.length === 0) { |
| 1147 | hooksTree.splice(i, 1); |
| 1148 | i--; |
| 1149 | debugValueHooksNodes.push(hooksNode); |
| 1150 | } else { |
| 1151 | processDebugValues(hooksNode.subHooks, hooksNode); |
| 1152 | } |
| 1153 | } |
| 1154 | |
| 1155 | class="cm">// Bubble debug value labels to their custom hook owner. |
| 1156 | class="cm">// If there is no parent hook, just ignore them for now. |
| 1157 | class="cm">// (We may warn about this in the future.) |
| 1158 | if (parentHooksNode !== null) { |
| 1159 | if (debugValueHooksNodes.length === 1) { |
| 1160 | parentHooksNode.value = debugValueHooksNodes[0].value; |
| 1161 | } else if (debugValueHooksNodes.length > 1) { |
| 1162 | parentHooksNode.value = debugValueHooksNodes.map(({value}) => value); |
| 1163 | } |
| 1164 | } |
| 1165 | } |
| 1166 | |
| 1167 | function handleRenderFunctionError(error: any): void { |
| 1168 | class="cm">// original error might be any type. |