( request: Request, task: Task, type: any, key: null | string, ref: mixed, props: any, validated: number, // DEV only )
| 2100 | } |
| 2101 | |
| 2102 | function renderElement( |
| 2103 | request: Request, |
| 2104 | task: Task, |
| 2105 | type: any, |
| 2106 | key: null | string, |
| 2107 | ref: mixed, |
| 2108 | props: any, |
| 2109 | validated: number, // DEV only |
| 2110 | ): ReactJSONValue { |
| 2111 | if (ref !== null && ref !== undefined) { |
| 2112 | // When the ref moves to the regular props object this will implicitly |
| 2113 | // throw for functions. We could probably relax it to a DEV warning for other |
| 2114 | // cases. |
| 2115 | // TODO: `ref` is now just a prop when `enableRefAsProp` is on. Should we |
| 2116 | // do what the above comment says? |
| 2117 | throw new Error( |
| 2118 | 'Refs cannot be used in Server Components, nor passed to Client Components.', |
| 2119 | ); |
| 2120 | } |
| 2121 | if (__DEV__) { |
| 2122 | jsxPropsParents.set(props, type); |
| 2123 | if (typeof props.children === 'object' && props.children !== null) { |
| 2124 | jsxChildrenParents.set(props.children, type); |
| 2125 | } |
| 2126 | } |
| 2127 | if ( |
| 2128 | typeof type === 'function' && |
| 2129 | !isClientReference(type) && |
| 2130 | !isOpaqueTemporaryReference(type) |
| 2131 | ) { |
| 2132 | // This is a Server Component. |
| 2133 | return renderFunctionComponent(request, task, key, type, props, validated); |
| 2134 | } else if (type === REACT_FRAGMENT_TYPE && key === null) { |
| 2135 | // For key-less fragments, we add a small optimization to avoid serializing |
| 2136 | // it as a wrapper. |
| 2137 | if (__DEV__ && validated === 2) { |
| 2138 | // Create a fake owner node for the error stack. |
| 2139 | const componentDebugInfo: ReactComponentInfo = { |
| 2140 | name: 'Fragment', |
| 2141 | env: (0, request.environmentName)(), |
| 2142 | key: key, |
| 2143 | owner: task.debugOwner, |
| 2144 | stack: |
| 2145 | task.debugStack === null |
| 2146 | ? null |
| 2147 | : filterStackTrace(request, parseStackTrace(task.debugStack, 1)), |
| 2148 | props: props, |
| 2149 | debugStack: task.debugStack, |
| 2150 | debugTask: task.debugTask, |
| 2151 | }; |
| 2152 | warnForMissingKey(request, key, componentDebugInfo, task.debugTask); |
| 2153 | } |
| 2154 | const prevImplicitSlot = task.implicitSlot; |
| 2155 | if (task.keyPath === null) { |
| 2156 | task.implicitSlot = true; |
| 2157 | } |
| 2158 | const json = renderModelDestructive( |
| 2159 | request, |
no test coverage detected