( request: Request, task: Task, type: any, key: null | string, props: any, validated: number, // DEV-only )
| 1963 | } |
| 1964 | |
| 1965 | function renderClientElement( |
| 1966 | request: Request, |
| 1967 | task: Task, |
| 1968 | type: any, |
| 1969 | key: null | string, |
| 1970 | props: any, |
| 1971 | validated: number, // DEV-only |
| 1972 | ): ReactJSONValue { |
| 1973 | // We prepend the terminal client element that actually gets serialized with |
| 1974 | // the keys of any Server Components which are not serialized. |
| 1975 | const keyPath = task.keyPath; |
| 1976 | if (key === null) { |
| 1977 | key = keyPath; |
| 1978 | } else if (keyPath !== null) { |
| 1979 | key = keyPath + ',' + key; |
| 1980 | } |
| 1981 | let debugOwner = null; |
| 1982 | let debugStack = null; |
| 1983 | if (__DEV__) { |
| 1984 | debugOwner = task.debugOwner; |
| 1985 | if (debugOwner !== null) { |
| 1986 | // Ensure we outline this owner if it is the first time we see it. |
| 1987 | // So that we can refer to it directly. |
| 1988 | outlineComponentInfo(request, debugOwner); |
| 1989 | } |
| 1990 | if (task.debugStack !== null) { |
| 1991 | // Outline the debug stack so that we write to the completedDebugChunks instead. |
| 1992 | debugStack = filterStackTrace( |
| 1993 | request, |
| 1994 | parseStackTrace(task.debugStack, 1), |
| 1995 | ); |
| 1996 | const id = outlineDebugModel( |
| 1997 | request, |
| 1998 | {objectLimit: debugStack.length * 2 + 1}, |
| 1999 | debugStack, |
| 2000 | ); |
| 2001 | // We also store this in the main dedupe set so that it can be referenced by inline React Elements. |
| 2002 | request.writtenObjects.set(debugStack, serializeByValueID(id)); |
| 2003 | } |
| 2004 | } |
| 2005 | const element = __DEV__ |
| 2006 | ? [REACT_ELEMENT_TYPE, type, key, props, debugOwner, debugStack, validated] |
| 2007 | : [REACT_ELEMENT_TYPE, type, key, props]; |
| 2008 | if (task.implicitSlot && key !== null) { |
| 2009 | // The root Server Component had no key so it was in an implicit slot. |
| 2010 | // If we had a key lower, it would end up in that slot with an explicit key. |
| 2011 | // We wrap the element in a fragment to give it an implicit key slot with |
| 2012 | // an inner explicit key. |
| 2013 | return [element]; |
| 2014 | } |
| 2015 | // Since we're yielding here, that implicitly resets the keyPath context on the |
| 2016 | // way up. Which is what we want since we've consumed it. If this changes to |
| 2017 | // be recursive serialization, we need to reset the keyPath and implicitSlot, |
| 2018 | // before recursing here. We also need to reset it once we render into an array |
| 2019 | // or anything else too which we also get implicitly. |
| 2020 | return element; |
| 2021 | } |
| 2022 |
no test coverage detected