prefix
stringlengths
512
512
suffix
stringlengths
256
256
middle
stringlengths
14
229
meta
dict
iates. * * This source code is licensed under the MIT license found in the * LICENSE file in the root directory of this source tree. * * @emails react-core * * @jest-environment node */ 'use strict'; let useSyncExternalStore; let React; let ReactDOM; let ReactDOMServer; let Scheduler; let assertLog; // This ...
de useSyncExternalStore. // // Longer term, we'll probably test this branch using an actual build of // React 17. jest.mock('react', () => { const { startTransition: _, useSyncExternalStore: __, ...otherExports
jest.resetModules(); // Remove useSyncExternalStore from the React imports so that we use the // shim instead. Also removing startTransition, since we use that to detect // outdated 18 alphas that don't yet inclu
{ "filepath": "packages/use-sync-external-store/src/__tests__/useSyncExternalStoreShimServer-test.js", "language": "javascript", "file_size": 2580, "cut_index": 563, "middle_length": 229 }
ons/utils'); const {resolveFeatureFlags} = require('react-devtools-shared/buildUtils'); const semver = require('semver'); const {SUCCESSFUL_COMPILATION_MESSAGE} = require('./constants'); const {ReactVersion: currentReactVersion} = require('../../ReactVersions'); const NODE_ENV = process.env.NODE_ENV; if (!NODE_ENV) ...
isnt' set, we'll use the build folder // for both React DevTools and React const REACT_VERSION = process.env.REACT_VERSION ? semver.coerce(process.env.REACT_VERSION).version : currentReactVersion; const E2E_APP_BUILD_DIR = process.env.REACT_VERSION
-experimental', ); const __DEV__ = NODE_ENV === 'development'; const DEVTOOLS_VERSION = getVersionString(); // If the React version isn't set, we will use the // current React version instead. Likewise if the // React version
{ "filepath": "packages/react-devtools-shell/webpack-server.js", "language": "javascript", "file_size": 7005, "cut_index": 716, "middle_length": 229 }
ight (c) Meta Platforms, Inc. and affiliates. * * This source code is licensed under the MIT license found in the * LICENSE file in the root directory of this source tree. * * @flow */ function ignoreStrings( methodName: string, stringsToIgnore: Array<string>, ): void { // $FlowFixMe[prop-missing] index ac...
e. // Our test app code uses the iframe's console though. // To simulate a more accurate end-to-end environment, // the shell's console patching should pass through to the parent override methods. window.parent.console[methodName](...args);
r (let i = 0; i < stringsToIgnore.length; i++) { if (maybeString.startsWith(stringsToIgnore[i])) { return; } } } // HACKY In the test harness, DevTools overrides the parent window's consol
{ "filepath": "packages/react-devtools-shell/src/app/console.js", "language": "javascript", "file_size": 1353, "cut_index": 524, "middle_length": 229 }
import {createRoot} from 'react-dom/client'; import { activate as activateBackend, initialize as initializeBackend, } from 'react-devtools-inline/backend'; import {initialize as initializeFrontend} from 'react-devtools-inline/frontend'; import {initDevTools} from 'react-devtools-shared/src/devtools'; // This is a ...
tentWindow.__REACT_DEVTOOLS_TARGET_WINDOW__ = window; initializeBackend(contentWindow); // Initialize the front end and activate the backend early so that we are able // to pass console settings in local storage to the backend before initial render const
public_path__ = '/dist/'; // eslint-disable-line no-undef const iframe = ((document.getElementById('target'): any): HTMLIFrameElement); const {contentDocument, contentWindow} = iframe; // Helps with positioning Overlay UI. con
{ "filepath": "packages/react-devtools-shell/src/app/devtools.js", "language": "javascript", "file_size": 2866, "cut_index": 563, "middle_length": 229 }
ions. import semver from 'semver'; import {createElement} from 'react'; import {createRoot} from 'react-dom/client'; import DeeplyNestedComponents from './DeeplyNestedComponents'; import Iframe from './Iframe'; import EditableProps from './EditableProps'; import ElementTypes from './ElementTypes'; import Hydration f...
TraceUpdatesTest from './TraceUpdatesTest'; import {ignoreErrors, ignoreLogs, ignoreWarnings} from './console'; import './styles.css'; // DevTools intentionally tests compatibility with certain legacy APIs. // Suppress their error messages in the local d
ort ErrorBoundaries from './ErrorBoundaries'; import PartiallyStrictApp from './PartiallyStrictApp'; import Segments from './Segments'; import SuspenseTree from './SuspenseTree'; import ActivityTree from './ActivityTree'; import
{ "filepath": "packages/react-devtools-shell/src/app/index.js", "language": "javascript", "file_size": 3877, "cut_index": 614, "middle_length": 229 }
('This warning fires during every render'); return children; } // $FlowFixMe[missing-local-annot] function WarnOnMount({children = null}) { useEffect(() => { console.warn('This warning fires on initial mount only'); }, []); return children; } // $FlowFixMe[missing-local-annot] function WarnOnUpdate({child...
}, []); return children; } // $FlowFixMe[missing-local-annot] function ErrorDuringRender({children = null}) { console.error('This error fires during every render'); return children; } // $FlowFixMe[missing-local-annot] function ErrorOnMount({child
current = true; } }); return children; } // $FlowFixMe[missing-local-annot] function WarnOnUnmount({children = null}) { useEffect(() => { return () => { console.warn('This warning fires on unmount'); };
{ "filepath": "packages/react-devtools-shell/src/app/InlineWarnings/index.js", "language": "javascript", "file_size": 5904, "cut_index": 716, "middle_length": 229 }
agment> <h1>Suspense</h1> <h4>Primary to Fallback Cycle</h4> <PrimaryFallbackTest initialSuspend={false} /> <h4>Fallback to Primary Cycle</h4> <PrimaryFallbackTest initialSuspend={true} /> <NestedSuspenseTest /> <SuspenseListTest /> <EmptySuspense /> <SuspenseTreeOp...
</p> ), d: ( <Suspense key="d" name="d"> <div>D</div> </Suspense> ), e: ( <Suspense key="e" name="e"> <IgnoreMePassthrough key="e1"> <Suspense name="e-child-one"> <p>e1</p> </Suspense> </Ig
<Suspense key="a" name="a"> <p>A</p> </Suspense> ), b: ( <div key="b"> <Suspense name="b">B</Suspense> </div> ), c: ( <p key="c"> <Suspense key="c" name="c"> C </Suspense>
{ "filepath": "packages/react-devtools-shell/src/app/SuspenseTree/index.js", "language": "javascript", "file_size": 9402, "cut_index": 921, "middle_length": 229 }
Platforms, Inc. and affiliates. * * This source code is licensed under the MIT license found in the * LICENSE file in the root directory of this source tree. * * @flow */ import * as React from 'react'; import { createContext, forwardRef, lazy, memo, Component, Fragment, Profiler, StrictMode, ...
); const ForwardRefComponent = forwardRef(function NamedInnerFunction(props, ref) { return <ClassComponent ref={ref} {...props} />; }); const ForwardRefComponentWithCustomDisplayName = forwardRef((props, ref) => ( <ClassComponent ref={ref} {...props} /
} function FunctionComponent() { return null; } const MemoFunctionComponent = memo(FunctionComponent); const ForwardRefComponentWithAnonymousFunction = forwardRef((props, ref) => ( <ClassComponent ref={ref} {...props} /> )
{ "filepath": "packages/react-devtools-shell/src/app/ElementTypes/index.js", "language": "javascript", "file_size": 1904, "cut_index": 537, "middle_length": 229 }
eNamedFunction() {} function formatContextForDisplay(name: string, value: any | string) { return ( <li> {name}: <pre>{JSON.stringify(value, null, 2)}</pre> </li> ); } const contextData = { array: ['first', 'second', 'third'], bool: true, func: someNamedFunction, number: 123, object: {outer...
ropTypes.func, number: PropTypes.number, object: PropTypes.object, string: PropTypes.string, symbol: PropTypes.symbol, null: PropTypes.any, undefined: PropTypes.any, }; getChildContext(): { array: Array<string>, bool: b
pes: { array: any, bool: any, func: any, null: any, number: any, object: any, string: any, symbol: any, undefined: any, } = { array: PropTypes.array, bool: PropTypes.bool, func: P
{ "filepath": "packages/react-devtools-shell/src/app/InspectableElements/Contexts.js", "language": "javascript", "file_size": 10031, "cut_index": 921, "middle_length": 229 }
import * as React from 'react'; import { createContext, forwardRef, Fragment, memo, useCallback, useContext, useDebugValue, useEffect, useOptimistic, useState, use, } from 'react'; import {useFormState, useFormStatus} from 'react-dom'; const object = { string: 'abc', number: 123, boolean: t...
useDebugValue('useDeepHookB'); useDeepHookC(); } function useDeepHookC() { useDebugValue('useDeepHookC'); useDeepHookD(); } function useDeepHookD() { useDebugValue('useDeepHookD'); useDeepHookE(); } function useDeepHookE() { useDebugValue('useD
ok() { return useNestedInnerHook(); } function useCustomObject() { useDebugValue(object); return useState(123); } function useDeepHookA() { useDebugValue('useDeepHookA'); useDeepHookB(); } function useDeepHookB() {
{ "filepath": "packages/react-devtools-shell/src/app/InspectableElements/CustomHooks.js", "language": "javascript", "file_size": 6089, "cut_index": 716, "middle_length": 229 }
opyright (c) Meta Platforms, Inc. and affiliates. * * This source code is licensed under the MIT license found in the * LICENSE file in the root directory of this source tree. * * @flow */ import * as React from 'react'; const objectWithModifiedHasOwnProperty = { foo: 'abc', bar: 123, hasOwnProperty: true...
unction EdgeCaseObjects(): React.Node { return ( <ChildComponent objectWithModifiedHasOwnProperty={objectWithModifiedHasOwnProperty} objectWithNullProto={objectWithNullProto} /> ); } function ChildComponent(props: any) { return n
low objectWithNullProto.bar = 123; export default f
{ "filepath": "packages/react-devtools-shell/src/app/InspectableElements/EdgeCaseObjects.js", "language": "javascript", "file_size": 835, "cut_index": 520, "middle_length": 52 }
ight (c) Meta Platforms, Inc. and affiliates. * * This source code is licensed under the MIT license found in the * LICENSE file in the root directory of this source tree. * * @flow */ import * as React from 'react'; import {Fragment} from 'react'; import UnserializableProps from './UnserializableProps'; import ...
ectEvent'; import UseSyncExternalStore from './UseSyncExternalStore'; // TODO Add Immutable JS example export default function InspectableElements(): React.Node { return ( <Fragment> <h1>Inspectable elements</h1> <SimpleValues />
om './EdgeCaseObjects.js'; import NestedProps from './NestedProps'; import SimpleValues from './SimpleValues'; import SymbolKeys from './SymbolKeys'; import UseMemoCache from './UseMemoCache'; import UseEffectEvent from './UseEff
{ "filepath": "packages/react-devtools-shell/src/app/InspectableElements/InspectableElements.js", "language": "javascript", "file_size": 1297, "cut_index": 524, "middle_length": 229 }
ight (c) Meta Platforms, Inc. and affiliates. * * This source code is licensed under the MIT license found in the * LICENSE file in the root directory of this source tree. * * @flow */ import * as React from 'react'; const object = { string: 'abc', longString: 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKJLMNOPQRS...
ect={{ // Known limitation: we won't go deeper than several levels. // In the future, we might offer a way to request deeper access on demand. a: { b: { c: { d: { e: {
ent object={{ outer: { inner: object, }, }} array={['first', 'second', 'third']} objectInArray={[object]} arrayInObject={{array: ['first', 'second', 'third']}} deepObj
{ "filepath": "packages/react-devtools-shell/src/app/InspectableElements/NestedProps.js", "language": "javascript", "file_size": 1429, "cut_index": 524, "middle_length": 229 }
, Inc. and affiliates. * * This source code is licensed under the MIT license found in the * LICENSE file in the root directory of this source tree. * * @flow */ import * as React from 'react'; import {Component} from 'react'; function noop() {} export default class SimpleValues extends Component { anonymous...
{Infinity} minusInfinity={-Infinity} true={true} false={false} function={noop} anonymousFunction={this.anonymousFunction} boundFunction={noop.bind(this)} regex={/abc[123]+/i} /> ); } } fu
null={null} nan={NaN} infinity=
{ "filepath": "packages/react-devtools-shell/src/app/InspectableElements/SimpleValues.js", "language": "javascript", "file_size": 908, "cut_index": 547, "middle_length": 52 }
Platforms, Inc. and affiliates. * * This source code is licensed under the MIT license found in the * LICENSE file in the root directory of this source tree. * * @flow */ import * as React from 'react'; const base = Object.create(Object.prototype, { enumerableStringBase: { value: 1, writable: true, ...
writable: true, enumerable: false, configurable: true, }, }); const data = Object.create(base, { enumerableString: { value: 2, writable: true, enumerable: true, configurable: true, }, nonEnumerableString: { value: 3
gurable: true, }, nonEnumerableStringBase: { value: 1, writable: true, enumerable: false, configurable: true, }, // $FlowFixMe[invalid-computed-prop] [Symbol('nonEnumerableSymbolBase')]: { value: 1,
{ "filepath": "packages/react-devtools-shell/src/app/InspectableElements/SymbolKeys.js", "language": "javascript", "file_size": 1667, "cut_index": 537, "middle_length": 229 }
ight (c) Meta Platforms, Inc. and affiliates. * * This source code is licensed under the MIT license found in the * LICENSE file in the root directory of this source tree. * * @flow */ import * as React from 'react'; import Immutable from 'immutable'; const set = new Set(['abc', 123]); const map = new Map([ [...
': 'xyz', xyz: 1, }, }); const bigInt = BigInt(123); class Foo { flag = false; object: Object = { a: {b: {c: {d: 1}}}, }; } export default function UnserializableProps(): React.Node { return ( <ChildComponent arrayBuffer={arra
typedArray = Int8Array.from([100, -100, 0]); const arrayBuffer = typedArray.buffer; const dataView = new DataView(arrayBuffer); const immutable = Immutable.fromJS({ a: [{hello: 'there'}, 'fixed', true], b: 123, c: { '1
{ "filepath": "packages/react-devtools-shell/src/app/InspectableElements/UnserializableProps.js", "language": "javascript", "file_size": 1362, "cut_index": 524, "middle_length": 229 }
iates. * * This source code is licensed under the MIT license found in the * LICENSE file in the root directory of this source tree. * * @flow */ import * as React from 'react'; const {useState, useEffect, useSyncExternalStore} = React; // Create a simple external store for demonstratio function createStore<T>...
e; subscribers.forEach(callback => callback()); }, }; } const counterStore = createStore(0); const themeStore = createStore('light'); export default function UseSyncExternalStore(): React.Node { return ( <> <h2>useSyncExternalStor
void>(); return { subscribe(callback) { subscribers.add(callback); return () => subscribers.delete(callback); }, getSnapshot() { return value; }, setValue(newValue) { value = newValu
{ "filepath": "packages/react-devtools-shell/src/app/InspectableElements/UseSyncExternalStore.js", "language": "javascript", "file_size": 2962, "cut_index": 563, "middle_length": 229 }
Platforms, Inc. and affiliates. * * This source code is licensed under the MIT license found in the * LICENSE file in the root directory of this source tree. * * @flow */ import * as React from 'react'; import {Fragment} from 'react'; class ErrorBoundary extends React.Component { state: {hasError: boolean} =...
An error was thrown. </div> ); } const {children} = this.props; return ( <div style={{ border: '1px solid gray', borderRadius: '0.25rem', margin: '0.5rem', padding: '0
r) { return ( <div style={{ color: 'red', border: '1px solid red', borderRadius: '0.25rem', margin: '0.5rem', padding: '0.5rem', }}>
{ "filepath": "packages/react-devtools-shell/src/app/ErrorBoundaries/index.js", "language": "javascript", "file_size": 1617, "cut_index": 537, "middle_length": 229 }
import * as React from 'react'; import {Fragment} from 'react'; import {createPortal} from 'react-dom'; export default function Iframe(): React.Node { return ( <Fragment> <h2>Iframe</h2> <div> <Frame> <Greeting /> </Frame> </div> </Fragment> ); } const iframeS...
ment = iframe.contentDocument; document.open(); document.write(html); document.close(); setElement(document.getElementById('root')); } }, []); return ( <Fragment> <iframe title="Test Iframe" ref={ref} style={ifr
React.useLayoutEffect(function () { const iframe = ref.current; if (iframe) { const html = ` <!DOCTYPE html> <html> <body> <div id="root"></div> </body> </html> `; const docu
{ "filepath": "packages/react-devtools-shell/src/app/Iframe/index.js", "language": "javascript", "file_size": 1339, "cut_index": 524, "middle_length": 229 }
ource code is licensed under the MIT license found in the * LICENSE file in the root directory of this source tree. * * @flow */ import * as React from 'react'; import {Fragment} from 'react'; function wrapWithHoc(Component: () => any, index: number) { function HOC() { return <Component />; } const dis...
= wrapWithHoc(Component, i); } return Component; } function Nested() { return <div>Deeply nested div</div>; } const DeeplyNested = wrapWithNested(Nested, 100); export default function DeeplyNestedComponents(): React.Node { return ( <Fragme
{ for (let i = 0; i < times; i++) { Component
{ "filepath": "packages/react-devtools-shell/src/app/DeeplyNestedComponents/index.js", "language": "javascript", "file_size": 979, "cut_index": 582, "middle_length": 52 }
ight (c) Meta Platforms, Inc. and affiliates. * * This source code is licensed under the MIT license found in the * LICENSE file in the root directory of this source tree. * * @flow */ import * as React from 'react'; import {Fragment, useState} from 'react'; import {Button, Text, View} from 'react-native-web'; ...
4\u063A\u0629 \u0627\u0644\u0639\u0631\u0628\u064A\u0629 auto (default) - arabic RTL' } </Text> <Text style={{textAlign: 'left'}}> left left left left left left left left left left left left left left left
= 'purple' ? 'green' : 'purple'); return ( <Fragment> <h1>ReactNativeWeb</h1> <View> <Text>auto (default) - english LTR</Text> <Text> { '\u0623\u062D\u0628 \u0627\u0644\u064
{ "filepath": "packages/react-devtools-shell/src/app/ReactNativeWeb/index.js", "language": "javascript", "file_size": 1277, "cut_index": 524, "middle_length": 229 }
iates. * * This source code is licensed under the MIT license found in the * LICENSE file in the root directory of this source tree. * * @flow */ import * as React from 'react'; import {Fragment, useCallback, useState} from 'react'; import ListItem from './ListItem'; import styles from './List.css'; export type...
D] = useState<number>(4); const handleClick = useCallback(() => { if (newItemText !== '') { setItems([ ...items, { id: uid, isComplete: false, text: newItemText, }, ]); setUID(u
tring>(''); const [items, setItems] = useState<Array<Item>>([ {id: 1, isComplete: true, text: 'First'}, {id: 2, isComplete: true, text: 'Second'}, {id: 3, isComplete: false, text: 'Third'}, ]); const [uid, setUI
{ "filepath": "packages/react-devtools-shell/src/app/ToDoList/List.js", "language": "javascript", "file_size": 2807, "cut_index": 563, "middle_length": 229 }
Copyright (c) Meta Platforms, Inc. and affiliates. * * This source code is licensed under the MIT license found in the * LICENSE file in the root directory of this source tree. * * @flow */ import * as React from 'react'; import {memo, useCallback} from 'react'; import styles from './ListItem.css'; import type...
<button className={styles.IconButton} onClick={handleDelete}> 🗑 </button> <label className={styles.Label}> <input className={styles.Input} checked={item.isComplete} onChange={handleToggle}
nst handleDelete = useCallback(() => { removeItem(item); }, [item, removeItem]); const handleToggle = useCallback(() => { toggleItem(item); }, [item, toggleItem]); return ( <li className={styles.ListItem}>
{ "filepath": "packages/react-devtools-shell/src/app/ToDoList/ListItem.js", "language": "javascript", "file_size": 1158, "cut_index": 518, "middle_length": 229 }
MIT license found in the * LICENSE file in the root directory of this source tree. * * @flow */ import type {ReactContext} from 'shared/ReactTypes'; import * as React from 'react'; import { createContext, Component, forwardRef, Fragment, memo, useCallback, useDebugValue, useEffect, useReducer, ...
Count] = useState(0); const debouncedCount = useDebounce(count, 1000); const handleUpdateCountClick = useCallback( () => updateCount(count + 1), [count], ); const [data, dispatch] = useReducer(reducer, initialData); const handleUpdateRed
e 'swap': return {foo: state.bar, bar: state.foo}; default: throw new Error(); } } type StatefulFunctionProps = {name: string}; function StatefulFunction({name}: StatefulFunctionProps) { const [count, update
{ "filepath": "packages/react-devtools-shell/src/app/EditableProps/index.js", "language": "javascript", "file_size": 4535, "cut_index": 614, "middle_length": 229 }
MIT license found in the * LICENSE file in the root directory of this source tree. * * @flow */ import * as React from 'react'; import {Fragment, useDebugValue, useState} from 'react'; const div = document.createElement('div'); const exampleFunction = () => {}; const typedArray = new Uint8Array(3); typedArray[0]...
}, qux: {}, quux: { k: undefined, l: null, }, }; function useOuterFoo() { useDebugValue({ debugA: { debugB: { debugC: 'abc', }, }, }); useState({ valueA: { valueB: { valueC: 'abc',
'q', 'r', 's'], ], [['t', 'u', 'v'], ['w', 'x', 'y'], ['z']], [], ]; const objectOfObjects = { foo: { a: 1, b: 2, c: 3, }, bar: { e: 4, f: 5, g: 6, }, baz: { h: 7, i: 8, j: 9,
{ "filepath": "packages/react-devtools-shell/src/app/Hydration/index.js", "language": "javascript", "file_size": 4761, "cut_index": 614, "middle_length": 229 }
iates. * * This source code is licensed under the MIT license found in the * LICENSE file in the root directory of this source tree. * * @flow */ import * as React from 'react'; import {useRef, useState} from 'react'; const Counter = () => { const [count, setCount] = useState(0); return ( <div> <...
n: '10px 0'}}> <button onClick={openDialog}>Open Dialog</button> <dialog ref={dialogRef} style={{padding: '20px'}}> <h3>Dialog Content</h3> <Counter /> <button onClick={closeDialog}>Close</button> </dialog> </d
log = () => { if (dialogRef.current) { dialogRef.current.showModal(); } }; const closeDialog = () => { if (dialogRef.current) { dialogRef.current.close(); } }; return ( <div style={{margi
{ "filepath": "packages/react-devtools-shell/src/app/TraceUpdatesTest/index.js", "language": "javascript", "file_size": 2026, "cut_index": 563, "middle_length": 229 }
iates. * * This source code is licensed under the MIT license found in the * LICENSE file in the root directory of this source tree. * * @flow */ import * as React from 'react'; function deferred<T>( timeoutMS: number, resolvedValue: T, displayName: string, ): Promise<T> { const promise = new Promise<T>...
tent}</p> </article> ); } function InnerSegment({children}: {children: React.Node}): React.Node { return ( <> <h3>Inner Segment</h3> <React.Suspense name="InnerSegment" fallback={<p>Loading...</p>}> <section>{children}</sec
le', 'title'); const content = deferred( 400, 'This is the content of a segmented page. It loads in multiple parts.', 'content', ); function Page(): React.Node { return ( <article> <h1>{title}</h1> <p>{con
{ "filepath": "packages/react-devtools-shell/src/app/Segments/index.js", "language": "javascript", "file_size": 2500, "cut_index": 563, "middle_length": 229 }
* Copyright (c) Meta Platforms, Inc. and affiliates. * * This source code is licensed under the MIT license found in the * LICENSE file in the root directory of this source tree. * * @flow */ import * as React from 'react'; import {useRef, useState} from 'react'; export default function App(): React.Node { ...
<button data-testname="AddItemButton" onClick={addItem}> Add Item </button> <ul data-testname="List"> {items.map((label, index) => ( <ListItem key={index} label={label} /> ))} </ul> </> ); } // $
rrent: any): HTMLInputElement); const text = input.value; input.value = ''; if (text) { setItems([...items, text]); } }; return ( <> <input ref={inputRef} data-testname="AddItemInput" />
{ "filepath": "packages/react-devtools-shell/src/e2e-apps/ListApp.js", "language": "javascript", "file_size": 1114, "cut_index": 515, "middle_length": 229 }
ight (c) Meta Platforms, Inc. and affiliates. * * This source code is licensed under the MIT license found in the * LICENSE file in the root directory of this source tree. * * @flow */ import * as React from 'react'; export default function App(): React.Node { return <List />; } class List extends React.Comp...
={this.state.text} onChange={this.onInputChange} ref={c => (this.inputRef = c)} /> <button data-testname="AddItemButton" onClick={this.addItem}> Add Item </button> <ul data-testname="List">
this.setState({items: [...this.state.items, this.inputRef.value]}); this.inputRef.value = ''; } }; render(): any { return ( <div> <input data-testname="AddItemInput" value
{ "filepath": "packages/react-devtools-shell/src/e2e-apps/ListAppLegacy.js", "language": "javascript", "file_size": 1281, "cut_index": 524, "middle_length": 229 }
eact'; import {createRoot} from 'react-dom/client'; import { activate as activateBackend, initialize as initializeBackend, } from 'react-devtools-inline/backend'; import {initialize as createDevTools} from 'react-devtools-inline/frontend'; // This is a pretty gross hack to make the runtime loaded named-hooks-code ...
teElement('script'); script.src = sourcePath; ((contentDocument.body: any): HTMLBodyElement).appendChild(script); } function init( appSource: string, appIframe: HTMLIFrameElement, devtoolsContainer: HTMLElement, loadDevToolsButton: HTMLButton
emove this prop after the Webpack 5 migration. function hookNamesModuleLoaderFunction() { return import('react-devtools-inline/hookNames'); } function inject(contentDocument, sourcePath) { const script = contentDocument.crea
{ "filepath": "packages/react-devtools-shell/src/perf-regression/devtools.js", "language": "javascript", "file_size": 1651, "cut_index": 537, "middle_length": 229 }
ight (c) Meta Platforms, Inc. and its affiliates. * * This source code is licensed under the MIT license found in the * LICENSE file in the root directory of this source tree. * * @flow */ import * as React from 'react'; function generateArray(size: number) { return Array.from({length: size}, () => Math.floor...
nce.now(); console.log( `Time spent on ${showList ? 'unmounting' : 'mounting'} the subtree: ${ afterRenderTime - startTime }ms`, ); }); }; return ( <div> <h2>Mount/Unmount a large subtree</h2> <
= () => { const startTime = performance.now(); setShowList(!showList); // requestAnimationFrame should happen after render+commit is done window.requestAnimationFrame(() => { const afterRenderTime = performa
{ "filepath": "packages/react-devtools-shell/src/perf-regression/apps/LargeSubtree.js", "language": "javascript", "file_size": 1281, "cut_index": 524, "middle_length": 229 }
Platforms, Inc. and affiliates. * * This source code is licensed under the MIT license found in the * LICENSE file in the root directory of this source tree. * * @noflow */ import * as React from 'react'; import * as ReactDOMClient from 'react-dom/client'; import { activate as activateBackend, initialize as...
after the Webpack 5 migration. function hookNamesModuleLoaderFunction() { return import('react-devtools-inline/hookNames'); } function inject(contentDocument, sourcePath, callback) { const script = contentDocument.createElement('script'); script.onl
ded named-hooks-code work. // TODO (Webpack 5) Hoepfully we can remove this once we upgrade to Webpack 5. __webpack_public_path__ = '/dist/'; // eslint-disable-line no-undef // TODO (Webpack 5) Hopefully we can remove this prop
{ "filepath": "packages/react-devtools-shell/src/e2e/devtools.js", "language": "javascript", "file_size": 1892, "cut_index": 537, "middle_length": 229 }
import type {CommitDataFrontend} from './types'; import * as React from 'react'; import {useEffect, useMemo, useRef, useState} from 'react'; import AutoSizer from 'react-virtualized-auto-sizer'; import {FixedSizeList} from 'react-window'; import SnapshotCommitListItem from './SnapshotCommitListItem'; import {minBarWid...
mitIndex: (index: number) => void, startCommitDrag: (newDragState: DragState) => void, totalDurations: Array<number>, }; type Props = { commitData: $ReadOnlyArray<CommitDataFrontend>, commitTimes: Array<number>, filteredCommitIndices: Array<numb
imes: Array<number>, filteredCommitIndices: Array<number>, maxDuration: number, selectedCommitIndex: number | null, selectedFilteredCommitIndex: number | null, selectCommitIndex: (index: number) => void, setHoveredCom
{ "filepath": "packages/react-devtools-shared/src/devtools/views/Profiler/SnapshotCommitList.js", "language": "javascript", "file_size": 8941, "cut_index": 716, "middle_length": 229 }
iates. * * This source code is licensed under the MIT license found in the * LICENSE file in the root directory of this source tree. * * @flow */ import * as React from 'react'; import {memo} from 'react'; import {areEqual} from 'react-window'; import {getGradientColor} from './utils'; import styles from './Sna...
dex = filteredCommitIndices[index]; const totalDuration = totalDurations[index]; // Use natural cbrt for bar height. // This prevents one (or a few) outliers from squishing the majority of other commits. // So rather than e.g. _█_ we get somethin
ta: itemData, index, style}: Props) { const { filteredCommitIndices, maxDuration, selectedCommitIndex, selectCommitIndex, setHoveredCommitIndex, startCommitDrag, totalDurations, } = itemData; in
{ "filepath": "packages/react-devtools-shared/src/devtools/views/Profiler/SnapshotCommitListItem.js", "language": "javascript", "file_size": 2624, "cut_index": 563, "middle_length": 229 }
ltip.css'; import typeof {SyntheticMouseEvent} from 'react-dom-bindings/src/events/SyntheticEvent'; const initialTooltipState = {height: 0, mouseX: 0, mouseY: 0, width: 0}; export default function Tooltip({ children, className, label, style, }: any): React.Node { const containerRef = useRef(null); const t...
{left, top} = getTooltipPosition(element, mousePosition); // update tooltip position element.style.left = left; element.style.top = top; } }; const onMouseMove = (event: SyntheticMouseEvent) => { updateTooltipPosition(event)
Ref.current; if (element != null) { // first find the mouse position const mousePosition = getMousePosition(containerRef.current, event); // use the mouse position to find the position of tooltip const
{ "filepath": "packages/react-devtools-shared/src/devtools/views/Profiler/Tooltip.js", "language": "javascript", "file_size": 3411, "cut_index": 614, "middle_length": 229 }
ight (c) Meta Platforms, Inc. and affiliates. * * This source code is licensed under the MIT license found in the * LICENSE file in the root directory of this source tree. * * @flow */ import * as React from 'react'; import {Fragment, useCallback, useContext} from 'react'; import {ProfilerContext} from './Profil...
); }); } const handleChange = useCallback( ({currentTarget}: $FlowFixMe) => { setRootID(parseInt(currentTarget.value, 10)); }, [setRootID], ); if (profilingData === null || profilingData.dataForRoots.size <= 1) { // Don
nst options = []; if (profilingData !== null) { profilingData.dataForRoots.forEach((dataForRoot, id) => { options.push( <option key={id} value={id}> {dataForRoot.displayName} </option>,
{ "filepath": "packages/react-devtools-shared/src/devtools/views/Profiler/RootSelector.js", "language": "javascript", "file_size": 1258, "cut_index": 524, "middle_length": 229 }
MIT license found in the * LICENSE file in the root directory of this source tree. * * @flow */ import * as React from 'react'; import {useContext} from 'react'; import {ProfilerContext} from './ProfilerContext'; import {StoreContext} from '../context'; import styles from './WhatChanged.css'; import HookChangeS...
ion filter update. // If the commit index is null, suspending for data below would throw an error. // TODO (ProfilerContext) This check should not be necessary. if (selectedCommitIndex === null) { return null; } const {changeDescriptions} =
: Props): React.Node { const {profilerStore} = useContext(StoreContext); const {rootID, selectedCommitIndex} = useContext(ProfilerContext); // TRICKY // Handle edge case where no commit is selected because of a min-durat
{ "filepath": "packages/react-devtools-shared/src/devtools/views/Profiler/WhatChanged.js", "language": "javascript", "file_size": 3588, "cut_index": 614, "middle_length": 229 }
import {useCallback, useMemo, useState} from 'react'; import {useLocalStorage} from '../hooks'; import type {CommitDataFrontend} from './types'; export type CommitFilteringAndNavigation = { isCommitFilterEnabled: boolean, setIsCommitFilterEnabled: (value: boolean) => void, minCommitDuration: number, setMinCom...
CommitDataFrontend>, ): CommitFilteringAndNavigation { // Filter settings persisted to localStorage const [isCommitFilterEnabled, setIsCommitFilterEnabledValue] = useLocalStorage<boolean>('React::DevTools::isCommitFilterEnabled', false); const [m
es: Array<number>, selectedFilteredCommitIndex: number | null, // Navigation selectNextCommitIndex: () => void, selectPrevCommitIndex: () => void, }; export function useCommitFilteringAndNavigation( commitData: Array<
{ "filepath": "packages/react-devtools-shared/src/devtools/views/Profiler/useCommitFilteringAndNavigation.js", "language": "javascript", "file_size": 6688, "cut_index": 716, "middle_length": 229 }
om 'react-devtools-shared/src/backend/types'; import type { ProfilingDataExport, ProfilingDataForRootExport, ProfilingDataForRootFrontend, ProfilingDataFrontend, SnapshotNode, } from './types'; import type { TimelineData, TimelineDataExport, } from 'react-devtools-timeline/src/types'; const commitGradien...
erer interfaces (backend) into the format required by the Profiler UI. // This format can then be quickly exported (and re-imported). export function prepareProfilingDataFrontendFromBackendAndStore( dataBackends: Array<ProfilingDataBackend>, operations
(--color-commit-gradient-5)', 'var(--color-commit-gradient-6)', 'var(--color-commit-gradient-7)', 'var(--color-commit-gradient-8)', 'var(--color-commit-gradient-9)', ]; // Combines info from the Store (frontend) and rend
{ "filepath": "packages/react-devtools-shared/src/devtools/views/Profiler/utils.js", "language": "javascript", "file_size": 11720, "cut_index": 921, "middle_length": 229 }
Platforms, Inc. and affiliates. * * This source code is licensed under the MIT license found in the * LICENSE file in the root directory of this source tree. * * @flow */ import * as React from 'react'; import Button from '../Button'; import ButtonIcon from '../ButtonIcon'; import styles from './shared.css'; t...
<div className={styles.HeaderRow}> <div className={styles.ErrorHeader}> Uncaught Error: {errorMessage || ''} </div> {dismissError !== null && ( <Button className={styles.CloseButton} onClick={di
rrorView({ callStack, children, componentStack, dismissError = null, errorMessage, }: Props): React.Node { return ( <div className={styles.ErrorBoundary}> {children} <div className={styles.ErrorInfo}>
{ "filepath": "packages/react-devtools-shared/src/devtools/views/ErrorBoundary/ErrorView.js", "language": "javascript", "file_size": 1527, "cut_index": 537, "middle_length": 229 }
* Copyright (c) Meta Platforms, Inc. and affiliates. * * This source code is licensed under the MIT license found in the * LICENSE file in the root directory of this source tree. * * @flow */ import * as React from 'react'; import {findGitHubIssue} from './cache'; import UpdateExistingIssue from './UpdateExist...
let GitHubUI; if (maybeItem != null) { GitHubUI = <UpdateExistingIssue gitHubIssue={maybeItem} />; } else { GitHubUI = ( <ReportNewIssue callStack={callStack} componentStack={componentStack} errorMessage={errorMe
sage: string | null, }; export default function SuspendingErrorView({ callStack, componentStack, errorMessage, }: Props): React.Node { const maybeItem = errorMessage !== null ? findGitHubIssue(errorMessage) : null;
{ "filepath": "packages/react-devtools-shared/src/devtools/views/ErrorBoundary/SuspendingErrorView.js", "language": "javascript", "file_size": 1103, "cut_index": 515, "middle_length": 229 }
ight (c) Meta Platforms, Inc. and affiliates. * * This source code is licensed under the MIT license found in the * LICENSE file in the root directory of this source tree. * * @flow */ import * as React from 'react'; import styles from './shared.css'; type Props = { callStack: string | null, children: React...
{errorMessage || 'Bridge protocol mismatch'} </div> </div> <div className={styles.InfoBox}> An incompatible version of <code>react-devtools-core</code> has been embedded in a renderer like React Native.
: Props): React.Node { return ( <div className={styles.ErrorBoundary}> {children} <div className={styles.ErrorInfo}> <div className={styles.HeaderRow}> <div className={styles.ErrorHeader}>
{ "filepath": "packages/react-devtools-shared/src/devtools/views/ErrorBoundary/UnsupportedBridgeOperationView.js", "language": "javascript", "file_size": 1431, "cut_index": 524, "middle_length": 229 }
ource code is licensed under the MIT license found in the * LICENSE file in the root directory of this source tree. * * @flow */ import * as React from 'react'; import {isInternalFacebookBuild} from 'react-devtools-feature-flags'; import {REACT_DEVTOOLS_WORKPLACE_URL} from 'react-devtools-shared/src/devtools/const...
<Icon className={styles.ReportIcon} type="facebook" /> <a className={styles.ReportLink} href={REACT_DEVTOOLS_WORKPLACE_URL} rel="noopener noreferrer" target="_blank"> Report this on Workplace </a>
<div className={styles.WorkplaceGroupRow}>
{ "filepath": "packages/react-devtools-shared/src/devtools/views/ErrorBoundary/WorkplaceGroup.js", "language": "javascript", "file_size": 979, "cut_index": 582, "middle_length": 52 }
Copyright (c) Meta Platforms, Inc. and affiliates. * * This source code is licensed under the MIT license found in the * LICENSE file in the root directory of this source tree. * * @flow */ export type GitHubIssue = { title: string, url: string, }; const GITHUB_ISSUES_API = 'https://api.github.com/search/i...
sage) + '%20' + filters.map(encodeURIComponent).join('%20') ); } export async function searchGitHubIssues( message: string, ): Promise<GitHubIssue | null> { const response = await fetch(searchGitHubIssuesURL(message)); const data = await r
onst filters = [ 'in:title', 'is:issue', 'is:open', 'is:public', 'label:"Component: Developer Tools"', 'repo:facebook/react', ]; return ( GITHUB_ISSUES_API + '?q=' + encodeURIComponent(mes
{ "filepath": "packages/react-devtools-shared/src/devtools/views/ErrorBoundary/githubAPI.js", "language": "javascript", "file_size": 1187, "cut_index": 518, "middle_length": 229 }
Copyright (c) Meta Platforms, Inc. and affiliates. * * This source code is licensed under the MIT license found in the * LICENSE file in the root directory of this source tree. * * @flow */ import * as React from 'react'; import {useImperativeHandle} from 'react'; import ContextMenu from './ContextMenu'; impor...
nst {shouldShow, position, hide} = useContextMenu(anchorElementRef); useImperativeHandle( ref, () => ({ isShown() { return shouldShow; }, hide, }), [shouldShow, hide], ); if (!shouldShow) { return close
items: ContextMenuItem[], closedMenuStub?: React.Node | null, ref?: ContextMenuRef, }; export default function ContextMenuContainer({ anchorElementRef, items, closedMenuStub = null, ref, }: Props): React.Node { co
{ "filepath": "packages/react-devtools-shared/src/devtools/ContextMenu/ContextMenuContainer.js", "language": "javascript", "file_size": 1167, "cut_index": 518, "middle_length": 229 }
iates. * * This source code is licensed under the MIT license found in the * LICENSE file in the root directory of this source tree. * * @flow */ import * as React from 'react'; import {useState, useEffect, useCallback} from 'react'; import type {ContextMenuPosition} from './types'; type Payload = { shouldSh...
); }, []); useEffect(() => { const anchor = anchorElementRef.current; if (anchor == null) return; function handleAnchorContextMenu(e: MouseEvent) { e.preventDefault(); e.stopPropagation(); const {pageX, pageY} = e;
const [shouldShow, setShouldShow] = useState(false); const [position, setPosition] = React.useState<ContextMenuPosition | null>( null, ); const hide = useCallback(() => { setShouldShow(false); setPosition(null
{ "filepath": "packages/react-devtools-shared/src/devtools/ContextMenu/useContextMenu.js", "language": "javascript", "file_size": 2197, "cut_index": 563, "middle_length": 229 }
import * as React from 'react'; import is from 'shared/objectIs'; // Intentionally not using named imports because Rollup uses dynamic // dispatch for CommonJS interop named imports. const {useState, useEffect, useLayoutEffect, useDebugValue} = React; let didWarnOld18Alpha = false; let didWarnUncachedGetSnapshot = fa...
this shim when the built-in API // does not exist. // // Do not assume that the clever hacks used by this hook also work in general. // The point of this shim is to replace the need for hacks by other libraries. export function useSyncExternalStore<T>(
it will break. The most important assumption // is that updates are always synchronous, because concurrent rendering is // only available in versions of React that also have a built-in // useSyncExternalStore API. And we only use
{ "filepath": "packages/use-sync-external-store/src/useSyncExternalStoreShimClient.js", "language": "javascript", "file_size": 5750, "cut_index": 716, "middle_length": 229 }
MIT license found in the * LICENSE file in the root directory of this source tree. * * @emails react-core * * @jest-environment node */ 'use strict'; let React; let ReactNoop; let Scheduler; let useSyncExternalStore; let useSyncExternalStoreWithSelector; let act; let assertLog; // This tests the userspace shi...
. // // Longer term, we'll probably test this branch using an actual build of // React 17. jest.mock('react', () => { const { startTransition: _, useSyncExternalStore: __, ...otherExports } = jest.require
; // Remove useSyncExternalStore from the React imports so that we use the // shim instead. Also removing startTransition, since we use that to detect // outdated 18 alphas that don't yet include useSyncExternalStore
{ "filepath": "packages/use-sync-external-store/src/__tests__/useSyncExternalStoreNative-test.js", "language": "javascript", "file_size": 4975, "cut_index": 614, "middle_length": 229 }
import * as React from 'react'; import {Fragment, useContext} from 'react'; import Button from '../Button'; import ButtonIcon from '../ButtonIcon'; import {ProfilerContext} from './ProfilerContext'; import SnapshotCommitList from './SnapshotCommitList'; import {maxBarWidth} from './constants'; import {StoreContext} fro...
t); const {commitData} = profilerStore.getDataForRoot(((rootID: any): number)); const totalDurations: Array<number> = []; const commitTimes: Array<number> = []; commitData.forEach(commitDatum => { totalDurations.push( commitDatum.duratio
tIndex, selectCommitIndex, selectPrevCommitIndex, selectNextCommitIndex, filteredCommitIndices, selectedFilteredCommitIndex, } = useContext(ProfilerContext); const {profilerStore} = useContext(StoreContex
{ "filepath": "packages/react-devtools-shared/src/devtools/views/Profiler/SnapshotSelector.js", "language": "javascript", "file_size": 5112, "cut_index": 716, "middle_length": 229 }
Platforms, Inc. and affiliates. * * This source code is licensed under the MIT license found in the * LICENSE file in the root directory of this source tree. * * @flow */ import type {CommitTree} from './types'; import type {SerializedElement} from 'react-devtools-shared/src/frontend/types'; import * as React ...
st children = updaters.length > 0 ? ( updaters.map((serializedElement: SerializedElement): React$Node => { const {displayName, id, key, type} = serializedElement; const isVisibleInTree = commitTree.nodes.has(id) && type
export type Props = { commitTree: CommitTree, updaters: Array<SerializedElement>, }; export default function Updaters({commitTree, updaters}: Props): React.Node { const {selectFiber} = useContext(ProfilerContext); con
{ "filepath": "packages/react-devtools-shared/src/devtools/views/Profiler/Updaters.js", "language": "javascript", "file_size": 1698, "cut_index": 537, "middle_length": 229 }
** * Copyright (c) Meta Platforms, Inc. and affiliates. * * This source code is licensed under the MIT license found in the * LICENSE file in the root directory of this source tree. * * @flow */ import * as React from 'react'; import styles from './shared.css'; type Props = { callStack: string | null, chil...
tyles.ErrorHeader}>{errorMessage}</div> </div> {!!info && <div className={styles.InfoBox}>{info}</div>} {!!callStack && ( <div className={styles.ErrorStack}> The error was thrown {callStack.trim()} </
Stack, errorMessage, }: Props): React.Node { return ( <div className={styles.ErrorBoundary}> {children} <div className={styles.ErrorInfo}> <div className={styles.HeaderRow}> <div className={s
{ "filepath": "packages/react-devtools-shared/src/devtools/views/ErrorBoundary/CaughtErrorView.js", "language": "javascript", "file_size": 1045, "cut_index": 513, "middle_length": 229 }
iates. * * This source code is licensed under the MIT license found in the * LICENSE file in the root directory of this source tree. * * @flow */ import * as React from 'react'; import Icon from '../Icon'; import {searchGitHubIssuesURL} from './githubAPI'; import styles from './shared.css'; const LABELS = [ '...
ess.env.GITHUB_URL; if (!bugURL) { return null; } const gitHubAPISearch = errorMessage !== null ? searchGitHubIssuesURL(errorMessage) : '(none)'; const title = `[DevTools Bug] ${errorMessage || ''}`; const parameters = [ `template=
{ callStack: string | null, componentStack: string | null, errorMessage: string | null, }; export default function ReportNewIssue({ callStack, componentStack, errorMessage, }: Props): React.Node { let bugURL = proc
{ "filepath": "packages/react-devtools-shared/src/devtools/views/ErrorBoundary/ReportNewIssue.js", "language": "javascript", "file_size": 2042, "cut_index": 563, "middle_length": 229 }
, Inc. and affiliates. * * This source code is licensed under the MIT license found in the * LICENSE file in the root directory of this source tree. * * @flow */ import type {GitHubIssue} from './githubAPI'; import * as React from 'react'; import Icon from '../Icon'; import styles from './shared.css'; export d...
" /> <div className={styles.UpdateExistingIssuePrompt}> Update existing issue: </div> <a className={styles.ReportLink} href={url} rel="noopener noreferrer" target="_blank" title="Report bug"
<Icon className={styles.ReportIcon} type="bug
{ "filepath": "packages/react-devtools-shared/src/devtools/views/ErrorBoundary/UpdateExistingIssue.js", "language": "javascript", "file_size": 902, "cut_index": 547, "middle_length": 52 }
MIT license found in the * LICENSE file in the root directory of this source tree. * * @flow */ import type { Thenable, FulfilledThenable, RejectedThenable, } from 'shared/ReactTypes'; import type {GitHubIssue} from './githubAPI'; import * as React from 'react'; import {unstable_getCacheForType as getCach...
tus === 'fulfilled') { return record.value; } else if (record.status === 'rejected') { return null; } else { throw record; } } type GitHubIssueMap = Map<string, Thenable<GitHubIssue>>; function createMap(): GitHubIssueMap { return new
) { try { // eslint-disable-next-line react-hooks-published/rules-of-hooks return React.use(record); } catch (x) { if (x === null) { return null; } throw x; } } if (record.sta
{ "filepath": "packages/react-devtools-shared/src/devtools/views/ErrorBoundary/cache.js", "language": "javascript", "file_size": 3890, "cut_index": 614, "middle_length": 229 }
MIT license found in the * LICENSE file in the root directory of this source tree. * * @flow */ import * as React from 'react'; import is from 'shared/objectIs'; import {useSyncExternalStore} from 'use-sync-external-store/src/useSyncExternalStore'; // Intentionally not using named imports because Rollup uses dyn...
isEqual?: (a: Selection, b: Selection) => boolean, ): Selection { type Inst = | { hasValue: true, value: Selection, } | { hasValue: false, value: null, }; // Use this to track the rendered snapshot.
useSyncExternalStoreWithSelector<Snapshot, Selection>( subscribe: (() => void) => () => void, getSnapshot: () => Snapshot, getServerSnapshot: void | null | (() => Snapshot), selector: (snapshot: Snapshot) => Selection,
{ "filepath": "packages/use-sync-external-store/src/useSyncExternalStoreWithSelector.js", "language": "javascript", "file_size": 4673, "cut_index": 614, "middle_length": 229 }
MIT license found in the * LICENSE file in the root directory of this source tree. * * @flow */ import * as React from 'react'; import {Fragment, useContext, useEffect, useRef} from 'react'; import WhatChanged from './WhatChanged'; import {ProfilerContext} from './ProfilerContext'; import {formatDuration, format...
ndex, selectedCommitIndex, selectedFiberID, selectedFiberName, selectFiber, } = useContext(ProfilerContext); const {profilingCache} = profilerStore; const selectedListItemRef = useRef<HTMLElement | null>(null); useEffect(() => {
edElementBadges'; import styles from './SidebarSelectedFiberInfo.css'; export default function SidebarSelectedFiberInfo(): React.Node { const {profilerStore} = useContext(StoreContext); const { rootID, selectCommitI
{ "filepath": "packages/react-devtools-shared/src/devtools/views/Profiler/SidebarSelectedFiberInfo.js", "language": "javascript", "file_size": 4339, "cut_index": 614, "middle_length": 229 }
MIT license found in the * LICENSE file in the root directory of this source tree. * * @flow */ import * as React from 'react'; import {Fragment, useContext} from 'react'; import {ProfilerContext} from './ProfilerContext'; import Updaters from './Updaters'; import {formatDuration, formatTime} from './utils'; impo...
v className={styles.NothingSelected}>Nothing selected</div>; } const { duration, effectDuration, passiveEffectDuration, priorityLevel, timestamp, updaters, } = profilerStore.getCommitData(rootID, selectedCommitIndex); cons
CommitInfo(_: Props): React.Node { const {selectedCommitIndex, rootID} = useContext(ProfilerContext); const {profilerStore} = useContext(StoreContext); if (rootID === null || selectedCommitIndex === null) { return <di
{ "filepath": "packages/react-devtools-shared/src/devtools/views/Profiler/SidebarCommitInfo.js", "language": "javascript", "file_size": 3880, "cut_index": 614, "middle_length": 229 }
ight (c) Meta Platforms, Inc. and affiliates. * * This source code is licensed under the MIT license found in the * LICENSE file in the root directory of this source tree. * * @flow */ import * as React from 'react'; import Button from '../Button'; import ButtonIcon from '../ButtonIcon'; import styles from './sh...
rInfo}> <div className={styles.HeaderRow}> <div className={styles.TimeoutHeader}> {errorMessage || 'Timed out waiting'} </div> <Button className={styles.CloseButton} onClick={dismissError}> Retr
tion TimeoutView({ callStack, children, componentStack, dismissError = null, errorMessage, }: Props): React.Node { return ( <div className={styles.ErrorBoundary}> {children} <div className={styles.Erro
{ "filepath": "packages/react-devtools-shared/src/devtools/views/ErrorBoundary/TimeoutView.js", "language": "javascript", "file_size": 1316, "cut_index": 524, "middle_length": 229 }
Copyright (c) Meta Platforms, Inc. and affiliates. * * This source code is licensed under the MIT license found in the * LICENSE file in the root directory of this source tree. * * @flow */ 'use strict'; // Intentionally not using named imports because Rollup uses dynamic // dispatch for CommonJS interop named...
oes is re-export useSyncExternalStore from the 'react' package, so " + 'it only works with React 18+.' + '\n\n' + 'If you wish to support React 16 and 17, import from ' + "'use-sync-external-store/shim' instead. It will fall back to
e built artifact // to access React internals, which exist under different paths depending on the // React version. console['error']( "The main 'use-sync-external-store' entry point is not supported; all it " + "d
{ "filepath": "packages/use-sync-external-store/src/useSyncExternalStore.js", "language": "javascript", "file_size": 1181, "cut_index": 518, "middle_length": 229 }
import type { ElementType, SerializedElement, } from 'react-devtools-shared/src/frontend/types'; import type { TimelineData, TimelineDataExport, } from 'react-devtools-timeline/src/types'; export type CommitTreeNode = { id: number, children: Array<number>, displayName: string | null, hocDisplayNames: A...
SnapshotNode = { id: number, children: Array<number>, displayName: string | null, hocDisplayNames: Array<string> | null, key: number | string | null, type: ElementType, // If component is compiled with Forget, the backend will send its name a
me as Forget(...) // Later, on the frontend side, we will strip HOC names and Forget prefix. compiledWithForget: boolean, }; export type CommitTree = { nodes: Map<number, CommitTreeNode>, rootID: number, }; export type
{ "filepath": "packages/react-devtools-shared/src/devtools/views/Profiler/types.js", "language": "javascript", "file_size": 5415, "cut_index": 716, "middle_length": 229 }
import * as React from 'react'; import {Component, Suspense} from 'react'; import Store from 'react-devtools-shared/src/devtools/store'; import UnsupportedBridgeOperationView from './UnsupportedBridgeOperationView'; import ErrorView from './ErrorView'; import SearchingGitHubIssues from './SearchingGitHubIssues'; import...
ct-devtools-shared/src/errors/UnknownHookError'; import {logEvent} from 'react-devtools-shared/src/Logger'; type Props = { children: React$Node, canDismiss?: boolean, onBeforeDismissCallback?: () => void, store?: Store, }; type State = { callSt
devtools-shared/src/UnsupportedBridgeOperationError'; import TimeoutError from 'react-devtools-shared/src/errors/TimeoutError'; import UserError from 'react-devtools-shared/src/errors/UserError'; import UnknownHookError from 'rea
{ "filepath": "packages/react-devtools-shared/src/devtools/views/ErrorBoundary/ErrorBoundary.js", "language": "javascript", "file_size": 6850, "cut_index": 716, "middle_length": 229 }
ate; useEffect = React.useEffect; useLayoutEffect = React.useLayoutEffect; const InternalTestUtils = require('internal-test-utils'); assertLog = InternalTestUtils.assertLog; assertConsoleErrorDev = InternalTestUtils.assertConsoleErrorDev; const internalAct = require('internal-test-utils').act; ...
-store` entrypoint. In the compiled artifacts, this // is resolved to the `shim` implementation by our build config, but when // running the tests against the source files, we need to tell Jest how to // resolve it. Because this is a sour
ode, I'm adding batching here. act = cb => internalAct(() => ReactDOM.unstable_batchedUpdates(cb)); if (gate(flags => flags.source)) { // The `shim/with-selector` module composes the main // `use-sync-external
{ "filepath": "packages/use-sync-external-store/src/__tests__/useSyncExternalStoreShared-test.js", "language": "javascript", "file_size": 33775, "cut_index": 2151, "middle_length": 229 }
MIT license found in the * LICENSE file in the root directory of this source tree. * * @flow */ import * as React from 'react'; import {useLayoutEffect} from 'react'; import {createPortal} from 'react-dom'; import ContextMenuItem from './ContextMenuItem'; import type { ContextMenuItem as ContextMenuItemType, ...
} } else { element.style.top = `${y}px`; } if (x + element.offsetWidth >= ownerWindow.innerWidth) { if (x - element.offsetWidth > 0) { element.style.left = `${x - element.offsetWidth}px`; } else { element.style.left = '0px';
ument.defaultView; if (y + element.offsetHeight >= ownerWindow.innerHeight) { if (y - element.offsetHeight > 0) { element.style.top = `${y - element.offsetHeight}px`; } else { element.style.top = '0px';
{ "filepath": "packages/react-devtools-shared/src/devtools/ContextMenu/ContextMenu.js", "language": "javascript", "file_size": 3490, "cut_index": 614, "middle_length": 229 }
iates. * * This source code is licensed under the MIT license found in the * LICENSE file in the root directory of this source tree. * * @emails react-core */ 'use strict'; jest.mock('react-dom-bindings/src/events/isEventSupported'); describe('InvalidEventListeners', () => { let React; let ReactDOMClient; ...
iner = null; }); it('should prevent non-function listeners, at dispatch', async () => { const root = ReactDOMClient.createRoot(container); await act(() => { root.render(<div onClick="not a function" />); }); assertConsoleErrorDev
t, assertConsoleErrorDev} = require('internal-test-utils')); container = document.createElement('div'); document.body.appendChild(container); }); afterEach(() => { document.body.removeChild(container); conta
{ "filepath": "packages/react-dom/src/__tests__/InvalidEventListeners-test.js", "language": "javascript", "file_size": 2636, "cut_index": 563, "middle_length": 229 }
recordID(id); event.stopPropagation(); }; const recordIDAndReturnFalse = function (id, event) { recordID(id); return false; }; const LISTENER = jest.fn(); const ON_CLICK_KEY = 'onClick'; let GRANDPARENT; let PARENT; let CHILD; let BUTTON; let renderTree; let putListener; let deleteAllListeners; let container;...
ner = document.createElement('div'); document.body.appendChild(container); let GRANDPARENT_PROPS = {}; let PARENT_PROPS = {}; let CHILD_PROPS = {}; let BUTTON_PROPS = {}; function Child(props) { return <div ref={c => (CHILD
ntEmitter', () => { beforeEach(() => { jest.resetModules(); LISTENER.mockClear(); React = require('react'); ReactDOMClient = require('react-dom/client'); act = require('internal-test-utils').act; contai
{ "filepath": "packages/react-dom/src/__tests__/ReactBrowserEventEmitter-test.js", "language": "javascript", "file_size": 10054, "cut_index": 921, "middle_length": 229 }
=> { jest.resetModules(); act = require('internal-test-utils').act; React = require('react'); ReactDOM = require('react-dom'); const InternalTestUtils = require('internal-test-utils'); waitForThrow = InternalTestUtils.waitForThrow; ErrorBoundary = class extends React.Component { stat...
windowOnError = jest.fn(); window.addEventListener('error', windowOnError); spyOnDevAndProd(console, 'error'); spyOnDevAndProd(console, 'warn'); }); afterEach(() => { document.body.removeChild(container); window.removeEventListe
r.message}</h1>; } return this.props.children; } }; NoError = function () { return <h1>OK</h1>; }; container = document.createElement('div'); document.body.appendChild(container);
{ "filepath": "packages/react-dom/src/__tests__/ReactDOMConsoleErrorReportingLegacy-test.js", "language": "javascript", "file_size": 16460, "cut_index": 921, "middle_length": 229 }
'); nativeEvent.initEvent('mouseout', true, true); childNode.dispatchEvent(nativeEvent); expect(mouseOut).toHaveBeenCalledTimes(2); expect(mouseOut).toHaveBeenNthCalledWith(1, childNode); expect(mouseOut).toHaveBeenNthCalledWith(2, parentNode); } finally { document...
dRoot = ReactDOMClient.createRoot(childContainer); const parentRoot = ReactDOMClient.createRoot(parentContainer); const grandParentRoot = ReactDOMClient.createRoot(grandParentContainer); await act(() => { childRoot.render(<div on
t(event.currentTarget); const childContainer = document.createElement('div'); const parentContainer = document.createElement('div'); const grandParentContainer = document.createElement('div'); const chil
{ "filepath": "packages/react-dom/src/__tests__/ReactDOMEventListener-test.js", "language": "javascript", "file_size": 40632, "cut_index": 2151, "middle_length": 229 }
, nativeEvent: 'focusout', dispatch(node) { const e = new Event('focusout', { bubbles: true, cancelable: true, }); node.dispatchEvent(e); }, }); }); // This test will fail in legacy mode (only used in WWW) // because we emu...
> { await testNativeBubblingEvent({ type: 'div', reactEvent: 'onContextMenu', reactEventType: 'contextmenu', nativeEvent: 'contextmenu', dispatch(node) { node.dispatchEvent( new MouseEvent
type: 'div', reactEvent: 'onClick', reactEventType: 'click', nativeEvent: 'click', dispatch(node) { node.click(); }, }); }); it('onContextMenu', async () =
{ "filepath": "packages/react-dom/src/__tests__/ReactDOMEventPropagation-test.js", "language": "javascript", "file_size": 83149, "cut_index": 3790, "middle_length": 229 }
('should render numbers as children', async () => { const Box = ({value}) => <div>{value}</div>; await act(async () => { root.render(<Box value={10} />); }); expect(container.textContent).toEqual('10'); }); it('should render bigints as children', async () => { const Box = ({value}) => <...
act(async () => { root.render(<Component />); }); assertLog(['Callback']); // updating phase await act(async () => { root.render(<Component />); }); assertLog(['Callback']); }); it('should call an effect when the
/update (replacing render callback pattern)', async () => { function Component() { React.useEffect(() => { Scheduler.log('Callback'); }); return <div>Foo</div>; } // mounting phase await
{ "filepath": "packages/react-dom/src/__tests__/ReactDOMFiber-test.js", "language": "javascript", "file_size": 37325, "cut_index": 2151, "middle_length": 229 }
rDev = require('internal-test-utils').assertConsoleErrorDev; Scheduler = require('scheduler'); const InternalTestUtils = require('internal-test-utils'); waitForAll = InternalTestUtils.waitForAll; waitFor = InternalTestUtils.waitFor; waitForMicrotasks = InternalTestUtils.waitForMicrotasks; ...
nder(<div>Bye</div>, container, () => { ops.push(container.textContent); }); expect(ops).toEqual(['Hi', 'Bye']); }); it('flushSync batches sync updates and flushes them at the end of the batch', async () => { const ops = []; let
// @gate !disableLegacyMode it('renders synchronously by default in legacy mode', () => { const ops = []; ReactDOM.render(<div>Hi</div>, container, () => { ops.push(container.textContent); }); ReactDOM.re
{ "filepath": "packages/react-dom/src/__tests__/ReactDOMFiberAsync-test.js", "language": "javascript", "file_size": 27544, "cut_index": 1331, "middle_length": 229 }
ct-core */ 'use strict'; import { insertNodesAndExecuteScripts, getVisibleChildren, } from '../test-utils/FizzTestUtils'; import {patchMessageChannel} from '../../../../scripts/jest/patchMessageChannel'; // Polyfills for test environment global.ReadableStream = require('web-streams-polyfill/ponyfill/es6').Rea...
tils').act; serverAct = require('internal-test-utils').serverAct; React = require('react'); ReactDOMServer = require('react-dom/server.browser'); ReactDOMClient = require('react-dom/client'); useDeferredValue = React.useDeferredValue;
OMClient; let useDeferredValue; let Suspense; describe('ReactDOMFizzForm', () => { beforeEach(() => { jest.resetModules(); Scheduler = require('scheduler'); patchMessageChannel(); act = require('internal-test-u
{ "filepath": "packages/react-dom/src/__tests__/ReactDOMFizzDeferredValue-test.js", "language": "javascript", "file_size": 5431, "cut_index": 716, "middle_length": 229 }
esetModules(); patchMessageChannel(); React = require('react'); ReactDOMServer = require('react-dom/server.browser'); ReactDOMClient = require('react-dom/client'); Suspense = React.Suspense; useFormStatus = require('react-dom').useFormStatus; useOptimistic = require('react').useOptimistic; ...
// useActionState = require('react-dom').useFormState; // } useActionState = require('react').useActionState; }); afterEach(() => { document.body.removeChild(container); }); function submit(submitter) { const form = submitter.fo
container = document.createElement('div'); document.body.appendChild(container); // TODO: Test the old api but it warns so needs warnings to be asserted. // if (__VARIANT__) { // Remove after API is deleted.
{ "filepath": "packages/react-dom/src/__tests__/ReactDOMFizzForm-test.js", "language": "javascript", "file_size": 24391, "cut_index": 1331, "middle_length": 229 }
resolveA = r; }); }); let resolveB; const LazyB = React.lazy(() => { return new Promise(r => { resolveB = r; }); }); class TextWithPunctuation extends React.Component { render() { return <Text text={this.props.text + this.props.punctuation} />; } ...
e fallback={<Text text="Loading..." />}> <LazyB text="world" /> </Suspense> </div> </div>, ); pipe(writable); }); expect(getVisibleChildren(container)).toEqual( <div> <div>Loadi
renderToPipeableStream( <div> <div> <Suspense fallback={<Text text="Loading..." />}> <LazyA text="Hello" /> </Suspense> </div> <div> <Suspens
{ "filepath": "packages/react-dom/src/__tests__/ReactDOMFizzServer-test.js", "language": "javascript", "file_size": 268234, "cut_index": 13624, "middle_length": 229 }
'); Suspense = React.Suspense; }); const theError = new Error('This is an error'); function Throw() { throw theError; } const theInfinitePromise = new Promise(() => {}); function InfiniteSuspend() { throw theInfinitePromise; } async function readResult(stream) { const reader = stream.g...
Result(stream); expect(result).toMatchInlineSnapshot(`"<div>hello world</div>"`); }); it('should emit DOCTYPE at the root of the document', async () => { const stream = await serverAct(() => ReactDOMFizzServer.renderToReadableStream(
g('utf8'); } } it('should call renderToReadableStream', async () => { const stream = await serverAct(() => ReactDOMFizzServer.renderToReadableStream(<div>hello world</div>), ); const result = await read
{ "filepath": "packages/react-dom/src/__tests__/ReactDOMFizzServerBrowser-test.js", "language": "javascript", "file_size": 18186, "cut_index": 1331, "middle_length": 229 }
ct-core */ 'use strict'; // Polyfills for test environment global.ReadableStream = require('web-streams-polyfill/ponyfill/es6').ReadableStream; global.TextEncoder = require('util').TextEncoder; global.AsyncLocalStorage = require('async_hooks').AsyncLocalStorage; let React; let ReactDOM; let ReactDOMFizzServer; le...
{done, value} = await reader.read(); if (done) { return result; } result += Buffer.from(value).toString('utf8'); } } // https://github.com/facebook/react/issues/27540 it('does not try to write to the stream after it has
ReactDOM = require('react-dom'); ReactDOMFizzServer = require('react-dom/server.edge'); }); async function readResult(stream) { const reader = stream.getReader(); let result = ''; while (true) { const
{ "filepath": "packages/react-dom/src/__tests__/ReactDOMFizzServerEdge-test.js", "language": "javascript", "file_size": 5768, "cut_index": 716, "middle_length": 229 }
output.result += chunk; }); writable.on('error', error => { output.error = error; }); const completed = new Promise(resolve => { writable.on('finish', () => { resolve(); }); writable.on('error', () => { resolve(); }); }); return {writable, complet...
return content; } content += Buffer.from(value).toString('utf8'); } } it('should call renderToPipeableStream', async () => { const {writable, output} = getTestWritable(); await act(() => { const {pipe} = ReactDOMFi
) { throw theInfinitePromise; } async function readContentWeb(stream) { const reader = stream.getReader(); let content = ''; while (true) { const {done, value} = await reader.read(); if (done) {
{ "filepath": "packages/react-dom/src/__tests__/ReactDOMFizzServerNode-test.js", "language": "javascript", "file_size": 19787, "cut_index": 1331, "middle_length": 229 }
Act = require('internal-test-utils').act; ReactDOMFizzServer = require('react-dom/server'); Stream = require('stream'); const InternalTestUtils = require('internal-test-utils'); assertLog = InternalTestUtils.assertLog; startTransition = React.startTransition; textCache = new Map(); // Te...
buffer += chunk; }); writable.on('error', error => { hasErrored = true; fatalError = error; }); }); afterEach(() => { jest.restoreAllMocks(); }); async function serverAct(callback) { await callback(); // Awa
m.window.document; container = document.getElementById('container'); buffer = ''; hasErrored = false; writable = new Stream.PassThrough(); writable.setEncoding('utf8'); writable.on('data', chunk => {
{ "filepath": "packages/react-dom/src/__tests__/ReactDOMFizzShellHydration-test.js", "language": "javascript", "file_size": 18135, "cut_index": 1331, "middle_length": 229 }
; let textCache; let document; let writable; let container; let buffer = ''; let hasErrored = false; let fatalError = undefined; describe('ReactDOMFizzStatic', () => { beforeEach(() => { jest.resetModules(); JSDOM = require('jsdom').JSDOM; React = require('react'); ReactDOM = require('react-dom'); ...
tainer = document.getElementById('container'); buffer = ''; hasErrored = false; writable = new Stream.PassThrough(); writable.setEncoding('utf8'); writable.on('data', chunk => { buffer += chunk; }); writable.on('error',
// Test Environment const jsdom = new JSDOM( '<!DOCTYPE html><html><head></head><body><div id="container">', { runScripts: 'dangerously', }, ); document = jsdom.window.document; con
{ "filepath": "packages/react-dom/src/__tests__/ReactDOMFizzStatic-test.js", "language": "javascript", "file_size": 10808, "cut_index": 921, "middle_length": 229 }
ontainer; let serverAct; describe('ReactDOMFizzStaticBrowser', () => { beforeEach(() => { jest.resetModules(); JSDOM = require('jsdom').JSDOM; // We need the mocked version of setTimeout inside the document. window.setTimeout = setTimeout; window.requestAnimationFrame = setTimeout; patchMes...
{ if (typeof global.window.__restoreGlobalScope === 'function') { global.window.__restoreGlobalScope(); } document.body.removeChild(container); }); const theError = new Error('This is an error'); function Throw() { throw theErr
equire('react-dom/static.browser'); Suspense = React.Suspense; SuspenseList = React.unstable_SuspenseList; container = document.createElement('div'); document.body.appendChild(container); }); afterEach(() =>
{ "filepath": "packages/react-dom/src/__tests__/ReactDOMFizzStaticBrowser-test.js", "language": "javascript", "file_size": 27960, "cut_index": 1331, "middle_length": 229 }
require('react'); ReactDOMFizzStatic = require('react-dom/static'); Suspense = React.Suspense; }); const theError = new Error('This is an error'); function Throw() { throw theError; } const theInfinitePromise = new Promise(() => {}); function InfiniteSuspend() { throw theInfinitePromise; ...
r(); let content = ''; while (true) { const {done, value} = await reader.read(); if (done) { return content; } content += Buffer.from(value).toString('utf8'); } } it('should call prerenderToNodeStream', asyn
'utf8'); }); readable.on('error', error => { reject(error); }); readable.on('end', () => resolve(content)); }); } async function readContentWeb(stream) { const reader = stream.getReade
{ "filepath": "packages/react-dom/src/__tests__/ReactDOMFizzStaticNode-test.js", "language": "javascript", "file_size": 10842, "cut_index": 921, "middle_length": 229 }
es(); JSDOM = require('jsdom').JSDOM; Scheduler = require('scheduler'); React = require('react'); ReactDOMClient = require('react-dom/client'); ReactDOMFizzServer = require('react-dom/server'); Stream = require('stream'); const InternalTestUtils = require('internal-test-utils'); waitFor...
utf8'); writable.on('data', chunk => { buffer += chunk; }); writable.on('error', error => { hasErrored = true; fatalError = error; }); }); async function act(callback) { await callback(); // Await one turn aro
gerously', }, ); document = jsdom.window.document; container = document.getElementById('container'); buffer = ''; hasErrored = false; writable = new Stream.PassThrough(); writable.setEncoding('
{ "filepath": "packages/react-dom/src/__tests__/ReactDOMFizzSuppressHydrationWarning-test.js", "language": "javascript", "file_size": 18572, "cut_index": 1331, "middle_length": 229 }
); assertLog = require('internal-test-utils').assertLog; ReactDOMFizzServer = require('react-dom/server'); Stream = require('stream'); Suspense = React.Suspense; SuspenseList = React.unstable_SuspenseList; Scheduler = require('scheduler'); // Test Environment const jsdom = new JSDOM( ...
setTimeout(cb); buffer = ''; hasErrored = false; hasCompleted = false; writable = new Stream.PassThrough(); writable.setEncoding('utf8'); writable.on('data', chunk => { buffer += chunk; }); writable.on('error'
getElementById('container'); global.window = jsdom.window; // The Fizz runtime assumes requestAnimationFrame exists so we need to polyfill it. global.requestAnimationFrame = global.window.requestAnimationFrame = cb =>
{ "filepath": "packages/react-dom/src/__tests__/ReactDOMFizzSuspenseList-test.js", "language": "javascript", "file_size": 23864, "cut_index": 1331, "middle_length": 229 }
ct-core * @jest-environment ./scripts/jest/ReactDOMServerIntegrationEnvironment */ 'use strict'; import { insertNodesAndExecuteScripts, getVisibleChildren, } from '../test-utils/FizzTestUtils'; let JSDOM; let React; let Suspense; let ViewTransition; let ReactDOMClient; let clientAct; let ReactDOMFizzServer; let...
t-dom/server'); Stream = require('stream'); Suspense = React.Suspense; ViewTransition = React.ViewTransition; // Test Environment const jsdom = new JSDOM( '<!DOCTYPE html><html><head></head><body><div id="container">', {
jest.resetModules(); JSDOM = require('jsdom').JSDOM; React = require('react'); ReactDOMClient = require('react-dom/client'); clientAct = require('internal-test-utils').act; ReactDOMFizzServer = require('reac
{ "filepath": "packages/react-dom/src/__tests__/ReactDOMFizzViewTransition-test.js", "language": "javascript", "file_size": 8617, "cut_index": 716, "middle_length": 229 }
' + href); }); } function resolveLoadables(hrefs, nodes, event, onLoad) { const hrefSet = hrefs ? new Set(hrefs) : null; for (let i = 0; i < nodes.length; i++) { const node = nodes[i]; if (loadCache.has(node)) { continue; } const href = node.getAttribute('href'); i...
o world</body> </html> </>, ); try { await waitForAll([]); } catch (e) { // for DOMExceptions that happen when expecting this test to fail we need // to clear the scheduler first otherwise the expected failure wi
c () => { const root = ReactDOMClient.createRoot(document); root.render( <> <title>foo</title> <html> <head> <link rel="foo" href="foo" /> </head> <body>hell
{ "filepath": "packages/react-dom/src/__tests__/ReactDOMFloat-test.js", "language": "javascript", "file_size": 311225, "cut_index": 13624, "middle_length": 229 }
{ Scheduler.log(`Suspend! [${text}]`); const thenable = { pings: [], then(resolve) { if (newRecord.status === 'pending') { thenable.pings.push(resolve); } else { Promise.resolve().then(() => resolve(newRecord.value)); } }, }...
} else { Promise.resolve().then(() => resolve(newRecord.value)); } }, }; const newRecord = { status: 'pending', value: thenable, }; textCache.set(text, newRecord); return t
const record = textCache.get(text); if (record === undefined) { const thenable = { pings: [], then(resolve) { if (newRecord.status === 'pending') { thenable.pings.push(resolve);
{ "filepath": "packages/react-dom/src/__tests__/ReactDOMForm-test.js", "language": "javascript", "file_size": 73807, "cut_index": 3790, "middle_length": 229 }
ef={fragmentRef}> <div id="childA">A</div> <div id="childB">B</div> </Fragment> <div id="childC">C</div> {show && <div id="childD">D</div>} </Fragment> ); } const root = ReactDOMClient.createRoot(container); await act(() => root.render(<Te...
ctFragments.has(fragmentParentRef.current)).toBe(true); expect(childB.reactFragments.has(fragmentParentRef.current)).toBe(true); expect(childC.reactFragments.has(fragmentParentRef.current)).toBe(true); await act(() => root.render(<Test show={t
pect(childA.reactFragments.has(fragmentRef.current)).toBe(true); expect(childB.reactFragments.has(fragmentRef.current)).toBe(true); expect(childC.reactFragments.has(fragmentRef.current)).toBe(false); expect(childA.rea
{ "filepath": "packages/react-dom/src/__tests__/ReactDOMFragmentRefs-test.js", "language": "javascript", "file_size": 87480, "cut_index": 3790, "middle_length": 229 }
ct-core */ 'use strict'; let React; let ReactDOM; let ReactDOMClient; let act; let waitForAll; describe('ReactDOMHooks', () => { let container; beforeEach(() => { jest.resetModules(); React = require('react'); ReactDOM = require('react-dom'); ReactDOMClient = require('react-dom/client'); a...
ontainer3 = document.createElement('div'); function Example1({n}) { React.useEffect(() => { ReactDOM.render(<Example2 n={n} />, container2); }); return 1 * n; } function Example2({n}) { React.useEffect(() => {
}); afterEach(() => { document.body.removeChild(container); }); // @gate !disableLegacyMode it('can ReactDOM.render() from useEffect', async () => { const container2 = document.createElement('div'); const c
{ "filepath": "packages/react-dom/src/__tests__/ReactDOMHooks-test.js", "language": "javascript", "file_size": 5148, "cut_index": 716, "middle_length": 229 }
MIT license found in the * LICENSE file in the root directory of this source tree. * * @emails react-core * @jest-environment ./scripts/jest/ReactDOMServerIntegrationEnvironment */ 'use strict'; let JSDOM; let React; let ReactDOMClient; let container; let waitForAll; describe('ReactDOM HostSingleton', () => { ...
ire('react'); ReactDOMClient = require('react-dom/client'); const InternalTestUtils = require('internal-test-utils'); waitForAll = InternalTestUtils.waitForAll; }); it('errors when a hoistable component becomes a Resource', async () => {
ontainer">', { runScripts: 'dangerously', }, ); global.window = jsdom.window; global.document = jsdom.window.document; container = global.document.getElementById('container'); React = requ
{ "filepath": "packages/react-dom/src/__tests__/ReactDOMHostComponentTransitions-test.js", "language": "javascript", "file_size": 4059, "cut_index": 614, "middle_length": 229 }
Message(args, index) { const ownerStack = ownerStacks[index]; if (ownerStack === undefined) { throw new Error( 'Expected an owner stack for message ' + index + ':\n' + util.format(...args), ); } const [format, ...rest] = args; if (format instanceof...
rest[rest.length - 1] = normalizeCodeLocInfo(rest[rest.length - 1]); return ( util.format(format, ...rest) + '\n Owner Stack:' + normalizeCodeLocInfo(ownerStack) ); } function formatConsoleErrors() { return console.e
\n Owner Stack:' + normalizeCodeLocInfo(ownerStack) ); } return ( 'Caught [' + format.message + ']\n Owner Stack:' + normalizeCodeLocInfo(ownerStack) ); }
{ "filepath": "packages/react-dom/src/__tests__/ReactDOMHydrationDiff-test.js", "language": "javascript", "file_size": 61726, "cut_index": 2151, "middle_length": 229 }
/** * Copyright (c) Meta Platforms, Inc. and affiliates. * * This source code is licensed under the MIT license found in the * LICENSE file in the root directory of this source tree. * * @emails react-core */ 'use strict'; describe('ReactDOMIframe', () => { let React; let ReactDOMClient; let act; befo...
adSpy})); }); const iframe = container.firstChild; const loadEvent = document.createEvent('Event'); loadEvent.initEvent('load', false, false); await act(() => { iframe.dispatchEvent(loadEvent); }); expect(onLoadSpy).toH
=> { const onLoadSpy = jest.fn(); const container = document.createElement('div'); const root = ReactDOMClient.createRoot(container); await act(() => { root.render(React.createElement('iframe', {onLoad: onLo
{ "filepath": "packages/react-dom/src/__tests__/ReactDOMIframe-test.js", "language": "javascript", "file_size": 1024, "cut_index": 512, "middle_length": 229 }
Array.isArray(arr)) { if (arr.length) { return arr[arr.length - 1]; } return undefined; } throw new Error('last was passed something that was not an array'); } function Text(props) { Scheduler.log(props.text); return props.text; } // function AsyncText(props) { // const text = props.text; ...
default'; Scheduler.log('Img ' + src); return <img src={src} onLoad={onLoad} />; } function Yield() { Scheduler.log('Yield'); Scheduler.unstable_requestPaint(); return null; } function loadImage(element) { const event = new Event('load'); e
Scheduler.log(`Suspend! [${text}]`); // } else { // Scheduler.log(`Error! [${text}]`); // } // throw promise; // } // } function Img({src: maybeSrc, onLoad, useImageLoader, ref}) { const src = maybeSrc || '
{ "filepath": "packages/react-dom/src/__tests__/ReactDOMImageLoad-test.internal.js", "language": "javascript", "file_size": 19554, "cut_index": 1331, "middle_length": 229 }
0 with missing onChange', async () => { await act(() => { root.render(<input type="text" value={0} />); }); assertConsoleErrorDev([ 'You provided a `value` prop to a form ' + 'field without an `onChange` handler. This will render a read-only ' + 'field. If the field should be mut...
er. This will render a read-only ' + 'field. If the field should be mutable use `defaultValue`. ' + 'Otherwise, set either `onChange` or `readOnly`.\n' + ' in input (at **)', ]); }); it('should warn for controlled value
ing onChange', async () => { await act(() => { root.render(<input type="text" value="" />); }); assertConsoleErrorDev([ 'You provided a `value` prop to a form ' + 'field without an `onChange` handl
{ "filepath": "packages/react-dom/src/__tests__/ReactDOMInput-test.js", "language": "javascript", "file_size": 102000, "cut_index": 3790, "middle_length": 229 }
MIT license found in the * LICENSE file in the root directory of this source tree. * * @emails react-core */ 'use strict'; describe('ReactDOMInvalidARIAHook', () => { let React; let ReactDOMClient; let mountComponent; let act; let assertConsoleErrorDev; beforeEach(() => { jest.resetModules(); ...
...props} />); }); }; }); describe('aria-* props', () => { it('should allow valid aria-* props', async () => { await mountComponent({'aria-label': 'Bumble bees'}); }); it('should allow new ARIA 1.3 attributes', async () =>
ertConsoleErrorDev; mountComponent = async function (props) { const container = document.createElement('div'); const root = ReactDOMClient.createRoot(container); await act(() => { root.render(<div {
{ "filepath": "packages/react-dom/src/__tests__/ReactDOMInvalidARIAHook-test.js", "language": "javascript", "file_size": 3664, "cut_index": 614, "middle_length": 229 }
Platforms, Inc. and affiliates. * * This source code is licensed under the MIT license found in the * LICENSE file in the root directory of this source tree. * * @emails react-core */ 'use strict'; describe('ReactDOMComponentTree', () => { let React; let ReactDOM; let container; let assertConsoleErrorD...
f node that is attempted to be unmounted', () => { const component = <div />; const node = ReactDOM.render(<div>{component}</div>, container); ReactDOM.unmountComponentAtNode(node); assertConsoleErrorDev([ "unmountComponentAtNode(): T
ner = document.createElement('div'); document.body.appendChild(container); }); afterEach(() => { document.body.removeChild(container); container = null; }); // @gate !disableLegacyMode it('finds instance o
{ "filepath": "packages/react-dom/src/__tests__/ReactDOMLegacyComponentTree-test.internal.js", "language": "javascript", "file_size": 1946, "cut_index": 537, "middle_length": 229 }
expect(called).toEqual(true); }); // @gate !disableLegacyMode it('should call a callback argument when the same element is re-rendered', () => { class Foo extends React.Component { render() { return <div>Foo</div>; } } const element = <Foo />; // mounting phase let called...
const Text = ({value}) => value; ReactDOM.render(<Text value="foo" />, container); expect(container.textContent).toEqual('foo'); }); // @gate !disableLegacyMode it('should render a component returning numbers directly from render', ()
> { ReactDOM.render(element, container, () => (called = true)); }); expect(called).toEqual(true); }); // @gate !disableLegacyMode it('should render a component returning strings directly from render', () => {
{ "filepath": "packages/react-dom/src/__tests__/ReactDOMLegacyFiber-test.js", "language": "javascript", "file_size": 42566, "cut_index": 2151, "middle_length": 229 }
ource code is licensed under the MIT license found in the * LICENSE file in the root directory of this source tree. * * @emails react-core * @jest-environment ./scripts/jest/ReactDOMServerIntegrationEnvironment */ 'use strict'; let React; let ReactDOMFizzServer; describe('ReactDOMFloat', () => { beforeEach(()...
oString( <html> <head> <script src="foo" /> <meta charSet="utf-8" /> <title>title</title> </head> </html>, ); expect(result).toEqual( '<html><head><meta charSet="utf-8"/>' + '
) => { const result = ReactDOMFizzServer.renderT
{ "filepath": "packages/react-dom/src/__tests__/ReactDOMLegacyFloat-test.js", "language": "javascript", "file_size": 984, "cut_index": 582, "middle_length": 52 }
reEach(() => { jest.resetModules(); container = document.createElement('div'); React = require('react'); ReactDOM = require('react-dom'); ReactDOMClient = require('react-dom/client'); Scheduler = require('scheduler'); act = require('internal-test-utils').act; const InternalTestUtils = r...
ignores discrete events on a pending removed element', async () => { const disableButtonRef = React.createRef(); const submitButtonRef = React.createRef(); function Form() { const [active, setActive] = React.useState(true); React.
ocument.body.removeChild(container); }); function dispatchAndSetCurrentEvent(el, event) { try { window.event = event; el.dispatchEvent(event); } finally { window.event = undefined; } } it('
{ "filepath": "packages/react-dom/src/__tests__/ReactDOMNativeEventHeuristic-test.js", "language": "javascript", "file_size": 12230, "cut_index": 921, "middle_length": 229 }
iates. * * This source code is licensed under the MIT license found in the * LICENSE file in the root directory of this source tree. * * @emails react-core */ 'use strict'; import {insertNodesAndExecuteScripts} from '../test-utils/FizzTestUtils'; import {patchMessageChannel} from '../../../../scripts/jest/patch...
); patchMessageChannel(); React = require('react'); ReactDOMServer = require('react-dom/server.browser'); assertLog = require('internal-test-utils').assertLog; serverAct = require('internal-test-utils').serverAct; container = docum
t React; let ReactDOMServer; let Scheduler; let assertLog; let container; let serverAct; describe('ReactClassComponentPropResolutionFizz', () => { beforeEach(() => { jest.resetModules(); Scheduler = require('scheduler'
{ "filepath": "packages/react-dom/src/__tests__/ReactClassComponentPropResolutionFizz-test.js", "language": "javascript", "file_size": 2706, "cut_index": 563, "middle_length": 229 }
('react'); ReactDOM = require('react-dom'); ReactDOMClient = require('react-dom/client'); ReactSharedInternals = require('react').__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE; Scheduler = require('scheduler'); assertLog = require('internal-test-utils').assertLog; ({act, ...
.setState({activated: !this.state.activated}); }; render() { const toggleActivatedState = this._toggleActivatedState; return !this.state.activated ? ( <a ref={this.xRef} onClick={toggleActivatedState} />
t = class extends React.Component { state = {activated: false}; xRef = React.createRef(); componentDidMount() { instance = this; } _toggleActivatedState = () => { this
{ "filepath": "packages/react-dom/src/__tests__/ReactCompositeComponent-test.js", "language": "javascript", "file_size": 38531, "cut_index": 2151, "middle_length": 229 }
iates. * * This source code is licensed under the MIT license found in the * LICENSE file in the root directory of this source tree. * * @emails react-core */ 'use strict'; // Requires let React; let ReactDOMClient; let act; // Test components let LowerLevelComposite; let MyCompositeComponent; /** * Integrat...
er() { return <div>{this.props.children}</div>; } }; MyCompositeComponent = class extends React.Component { render() { return <LowerLevelComposite>{this.props.children}</LowerLevelComposite>; } }; }); it(
sm', () => { beforeEach(() => { React = require('react'); ReactDOMClient = require('react-dom/client'); act = require('internal-test-utils').act; LowerLevelComposite = class extends React.Component { rend
{ "filepath": "packages/react-dom/src/__tests__/ReactCompositeComponentDOMMinimalism-test.js", "language": "javascript", "file_size": 2597, "cut_index": 563, "middle_length": 229 }