MCPcopy
hub / github.com/facebook/react / OutputContent

Function OutputContent

compiler/apps/playground/components/Editor/Output.tsx:258–325  ·  view source on GitHub ↗
({store, compilerOutput}: Props)

Source from the content-addressed store, hash-verified

256}
257
258function OutputContent({store, compilerOutput}: Props): JSX.Element {
259 const [tabsOpen, setTabsOpen] = useState<Set<string>>(
260 () => new Set(['Output']),
261 );
262 const [activeTab, setActiveTab] = useState<string>('Output');
263
264 /*
265 * Update the active tab back to the output or errors tab when the compilation state
266 * changes between success/failure.
267 */
268 const [previousOutputKind, setPreviousOutputKind] = useState(
269 compilerOutput.kind,
270 );
271 if (compilerOutput.kind !== previousOutputKind) {
272 setPreviousOutputKind(compilerOutput.kind);
273 setTabsOpen(new Set(['Output']));
274 setActiveTab('Output');
275 }
276 const changedPasses: Set<string> = new Set(['Output', 'HIR']); // Initial and final passes should always be bold
277 let lastResult: string = '';
278 for (const [passName, results] of compilerOutput.results) {
279 for (const result of results) {
280 let currResult = '';
281 if (result.kind === 'hir' || result.kind === 'reactive') {
282 currResult += `function ${result.fnName}\n\n${result.value}`;
283 }
284 if (currResult !== lastResult) {
285 changedPasses.add(passName);
286 }
287 lastResult = currResult;
288 }
289 }
290 const tabs = use(tabifyCached(store, compilerOutput));
291
292 if (!store.showInternals) {
293 return (
294 <ViewTransition
295 update={{
296 [CONFIG_PANEL_TRANSITION]: 'container',
297 [TOGGLE_INTERNALS_TRANSITION]: '',
298 default: 'none',
299 }}>
300 <TabbedWindow
301 tabs={tabs}
302 activeTab={activeTab}
303 onTabChange={setActiveTab}
304 />
305 </ViewTransition>
306 );
307 }
308
309 return (
310 <ViewTransition
311 update={{
312 [CONFIG_PANEL_TRANSITION]: 'accordion-container',
313 [TOGGLE_INTERNALS_TRANSITION]: '',
314 default: 'none',
315 }}>

Callers

nothing calls this directly

Calls 4

useStateFunction · 0.90
useFunction · 0.90
tabifyCachedFunction · 0.85
addMethod · 0.80

Tested by

no test coverage detected