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. * * @flow */ import ReactVersion from 'shared/ReactVersion'; import type {ReactNodeList} from 'shared/ReactTypes'; import { createRequest, startWork, startFlowing, abort,...
oolean, abortReason: string, ): string { let didFatal = false; let fatalError = null; let result = ''; const destination = { // $FlowFixMe[missing-local-annot] push(chunk) { if (chunk !== null) { result += chunk; }
type ServerOptions = { identifierPrefix?: string, }; function onError() { // Non-fatal errors are ignored. } function renderToStringImpl( children: ReactNodeList, options: void | ServerOptions, generateStaticMarkup: b
{ "filepath": "packages/react-dom/src/server/ReactDOMLegacyServerImpl.js", "language": "javascript", "file_size": 2538, "cut_index": 563, "middle_length": 229 }
ct-core */ let React; let ReactNoop; let Scheduler; let act; let Suspense; let SuspenseList; let getCacheForType; let caches; let seededCache; let assertLog; beforeEach(() => { React = require('react'); ReactNoop = require('react-noop-renderer'); Scheduler = require('scheduler'); act = require('internal-test...
eed a cache before it exists. // TODO: Need a built-in API to seed data before the initial render (i.e. // not a refresh because nothing has mounted yet). const cache = seededCache; seededCache = null; return cache; } const data =
)) { SuspenseList = React.unstable_SuspenseList; } getCacheForType = React.unstable_getCacheForType; caches = []; seededCache = null; }); function createTextCache() { if (seededCache !== null) { // Trick to s
{ "filepath": "packages/react-dom/src/__tests__/ReactWrongReturnPointer-test.js", "language": "javascript", "file_size": 5188, "cut_index": 716, "middle_length": 229 }
ct-core */ 'use strict'; const React = require('react'); const ReactDOM = require('react-dom'); const StrictMode = React.StrictMode; const assertConsoleErrorDev = require('internal-test-utils').assertConsoleErrorDev; describe('findDOMNode', () => { // @gate www && classic it('findDOMNode should return null if...
eactDOM.render(<MyNode />, container); const myDiv = ReactDOM.findDOMNode(myNode); const mySameDiv = ReactDOM.findDOMNode(myDiv); expect(myDiv.tagName).toBe('DIV'); expect(mySameDiv).toBe(myDiv); }); // @gate www && classic && !disable
yNode extends React.Component { render() { return ( <div> <span>Noise</span> </div> ); } } const container = document.createElement('div'); const myNode = R
{ "filepath": "packages/react-dom/src/__tests__/findDOMNodeFB-test.js", "language": "javascript", "file_size": 5320, "cut_index": 716, "middle_length": 229 }
MIT license found in the * LICENSE file in the root directory of this source tree. * * @emails react-core */ 'use strict'; let React; let ReactDOM; let ReactDOMClient; let TestComponent; let act; let theInnerDivRef; let theInnerClassComponentRef; describe('refs-destruction', () => { beforeEach(() => { jes...
eateRef(); theInnerClassComponentRef = React.createRef(); } render() { if (this.props.destroy) { return <div />; } else if (this.props.removeRef) { return ( <div> <div />
ClassComponent extends React.Component { render() { return null; } } TestComponent = class extends React.Component { constructor(props) { super(props); theInnerDivRef = React.cr
{ "filepath": "packages/react-dom/src/__tests__/refs-destruction-test.js", "language": "javascript", "file_size": 4646, "cut_index": 614, "middle_length": 229 }
; function initModules() { // Reset warning cache. jest.resetModules(); React = require('react'); ReactDOMServer = require('react-dom/server'); assertConsoleErrorDev = require('internal-test-utils').assertConsoleErrorDev; assertConsoleWarnDev = require('internal-test-utils').assertConsoleWarnDev; // Mak...
componentWillMount'); } render() { log.push('outer render'); return <Inner />; } } class Inner extends React.Component { UNSAFE_componentWillMount() { log.push('inner componentWillMount'); }
reEach(() => { resetModules(); }); it('should invoke the correct legacy lifecycle hooks', () => { const log = []; class Outer extends React.Component { UNSAFE_componentWillMount() { log.push('outer
{ "filepath": "packages/react-dom/src/__tests__/ReactDOMServerLifecycles-test.js", "language": "javascript", "file_size": 10907, "cut_index": 921, "middle_length": 229 }
t(mouseOutEvent); } // TODO: There's currently no React DOM API to opt into Idle priority updates, // and there's no native DOM event that maps to idle priority, so this is a // temporary workaround. Need something like ReactDOM.unstable_IdleUpdates. function TODO_scheduleIdleDOMSchedulerTask(fn) { ReactDOM.unstable...
} finally { window.event = prevEvent; } }); } describe('ReactDOMServerSelectiveHydrationActivity', () => { beforeEach(() => { jest.resetModules(); ReactFeatureFlags = require('shared/ReactFeatureFlags'); ReactFeatureFlags.ena
} }); } function TODO_scheduleContinuousSchedulerTask(fn) { ReactDOM.unstable_runWithPriority(ContinuousEventPriority, () => { const prevEvent = window.event; window.event = {type: 'message'}; try { fn();
{ "filepath": "packages/react-dom/src/__tests__/ReactDOMServerSelectiveHydrationActivity-test.internal.js", "language": "javascript", "file_size": 42425, "cut_index": 2151, "middle_length": 229 }
ler = require('scheduler'); let act; let useEffect; let assertLog; let waitForAll; let assertConsoleErrorDev; describe('ReactDOMRoot', () => { let container; beforeEach(() => { jest.resetModules(); container = document.createElement('div'); React = require('react'); ReactDOM = require('react-dom')...
itForAll = InternalTestUtils.waitForAll; }); it('renders children', async () => { const root = ReactDOMClient.createRoot(container); root.render(<div>Hi</div>); await waitForAll([]); expect(container.textContent).toEqual('Hi'); });
sertConsoleErrorDev = require('internal-test-utils').assertConsoleErrorDev; useEffect = React.useEffect; const InternalTestUtils = require('internal-test-utils'); assertLog = InternalTestUtils.assertLog; wa
{ "filepath": "packages/react-dom/src/__tests__/ReactDOMRoot-test.js", "language": "javascript", "file_size": 13580, "cut_index": 921, "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'; const ReactDOMServerIntegrationUtils = require('./utils/ReactDOMServerIntegrationTestUtils'); const TEXT_NODE_TYPE =...
initModules); describe('ReactDOMServerIntegration', () => { beforeEach(() => { resetModules(); }); describe('basic rendering', function () { itRenders('a blank div', async render => { const e = await render(<div />); expect(e.ta
-dom/client'); ReactDOMServer = require('react-dom/server'); // Make them available to the helpers. return { ReactDOMClient, ReactDOMServer, }; } const {resetModules, itRenders} = ReactDOMServerIntegrationUtils(
{ "filepath": "packages/react-dom/src/__tests__/ReactDOMServerIntegrationBasic-test.js", "language": "javascript", "file_size": 4796, "cut_index": 614, "middle_length": 229 }
ct-core * @jest-environment ./scripts/jest/ReactDOMServerIntegrationEnvironment */ 'use strict'; const ReactDOMServerIntegrationUtils = require('./utils/ReactDOMServerIntegrationTestUtils'); let React; let ReactDOMClient; let ReactDOMServer; function initModules() { // Reset warning cache. jest.resetModules()...
ntextType', function () { let PurpleContext, RedContext, Context; beforeEach(() => { Context = React.createContext('none'); class Parent extends React.Component { render() { return ( <Context.Provider valu
lient, ReactDOMServer, }; } const {resetModules, itRenders} = ReactDOMServerIntegrationUtils(initModules); describe('ReactDOMServerIntegration', () => { beforeEach(() => { resetModules(); }); describe('class co
{ "filepath": "packages/react-dom/src/__tests__/ReactDOMServerIntegrationClassContextType-test.js", "language": "javascript", "file_size": 7960, "cut_index": 716, "middle_length": 229 }
e).toMatch(value); } function expectTextNode(node, text) { expectNode(node, TEXT_NODE_TYPE, text); } describe('text children', function () { itRenders('a div with text', async render => { const e = await render(<div>Text</div>); expect(e.tagName).toBe('DIV'); expect...
ild', async render => { const e = await render(<div>{''}</div>); expect(e.childNodes.length).toBe(0); }); itRenders('a div with multiple empty text children', async render => { const e = await render( <div>
ttier-ignore const e = await render(<div> Text </div>); expect(e.childNodes.length).toBe(1); expectNode(e.childNodes[0], TEXT_NODE_TYPE, ' Text '); }); itRenders('a div with an empty text ch
{ "filepath": "packages/react-dom/src/__tests__/ReactDOMServerIntegrationElements-test.js", "language": "javascript", "file_size": 35245, "cut_index": 2151, "middle_length": 229 }
ct-core */ 'use strict'; let React; let ReactDOM; let findDOMNode; let ReactDOMClient; let Suspense; let Scheduler; let act; let textCache; let assertLog; describe('ReactDOMSuspensePlaceholder', () => { let container; beforeEach(() => { jest.resetModules(); React = require('react'); ReactDOM = requ...
.appendChild(container); textCache = new Map(); }); afterEach(() => { document.body.removeChild(container); }); function resolveText(text) { const record = textCache.get(text); if (record === undefined) { const newRecord =
duler = require('scheduler'); act = require('internal-test-utils').act; assertLog = require('internal-test-utils').assertLog; Suspense = React.Suspense; container = document.createElement('div'); document.body
{ "filepath": "packages/react-dom/src/__tests__/ReactDOMSuspensePlaceholder-test.js", "language": "javascript", "file_size": 8911, "cut_index": 716, "middle_length": 229 }
); document.body.appendChild(container); const IntersectionMocks = require('./utils/IntersectionMocks'); mockIntersectionObserver = IntersectionMocks.mockIntersectionObserver; simulateIntersection = IntersectionMocks.simulateIntersection; setBoundingClientRect = IntersectionMocks.setBoundingClientRe...
it act(() => { root.render(<Example />); }); const matches = findAllNodes(document.body, [ createComponentSelector(Example), createTestNameSelector('match'), ]); expect(matches).toHaveLength(1); expect
cument root', async () => { function Example() { return ( <div> <div data-testname="match" id="match" /> </div> ); } const root = createRoot(container); awa
{ "filepath": "packages/react-dom/src/__tests__/ReactDOMTestSelectors-test.js", "language": "javascript", "file_size": 39468, "cut_index": 2151, "middle_length": 229 }
'ReactEmptyComponent', () => { beforeEach(() => { jest.resetModules(); React = require('react'); ReactDOM = require('react-dom'); ReactDOMClient = require('react-dom/client'); findDOMNode = ReactDOM.__DOM_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE .findDOMNode; Sched...
() { Scheduler.log('mount ' + findDOMNode(this)?.nodeName); this.setState({component: this.props.secondComponent}); } componentDidUpdate() { Scheduler.log('update ' + findDOMNode(this)?.nodeName); } render(
ev = InternalTestUtils.assertConsoleErrorDev; container = document.createElement('div'); TogglingComponent = class extends React.Component { state = {component: this.props.firstComponent}; componentDidMount
{ "filepath": "packages/react-dom/src/__tests__/ReactEmptyComponent-test.js", "language": "javascript", "file_size": 10772, "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'; let React; let ReactDOMClient; let act; describe('ReactEventIndependence', () => { beforeEach(() => { jest.resetModules(); Reac...
<div onClick={() => clicks++} dangerouslySetInnerHTML={{ __html: '<button data-reactid=".z">click me</div>', }} />, ); }); container.firstElementChild.click(); expect(cl
t clicks = 0; const container = document.createElement('div'); document.body.appendChild(container); const root = ReactDOMClient.createRoot(container); try { await act(() => { root.render(
{ "filepath": "packages/react-dom/src/__tests__/ReactEventIndependence-test.js", "language": "javascript", "file_size": 2440, "cut_index": 563, "middle_length": 229 }
ct-core * @jest-environment ./scripts/jest/ReactDOMServerIntegrationEnvironment */ /* eslint-disable no-script-url */ 'use strict'; const ReactDOMServerIntegrationUtils = require('./utils/ReactDOMServerIntegrationTestUtils'); let React; let ReactDOMClient; let ReactDOMServer; let act; const EXPECTED_SAFE_URL = ...
he helpers. return { ReactDOMClient, ReactDOMServer, }; } const { resetModules, itRenders, clientCleanRender, clientRenderOnBadMarkup, clientRenderOnServerString, } = ReactDOMServerIntegrationUtils(initModules
est.resetModules(); React = require('react'); ReactDOMClient = require('react-dom/client'); ReactDOMServer = require('react-dom/server'); act = require('internal-test-utils').act; // Make them available to t
{ "filepath": "packages/react-dom/src/__tests__/ReactDOMServerIntegrationUntrustedURL-test.js", "language": "javascript", "file_size": 8380, "cut_index": 716, "middle_length": 229 }
MIT license found in the * LICENSE file in the root directory of this source tree. * * @emails react-core */ 'use strict'; describe('ReactStartTransitionMultipleRenderers', () => { let act; let container; let React; let ReactDOMClient; let Scheduler; let assertLog; let startTransition; let useOpt...
div'); document.body.appendChild(container); textCache = new Map(); }); function resolveText(text) { const record = textCache.get(text); if (record === undefined) { const newRecord = { status: 'resolved', value:
act = require('internal-test-utils').act; assertLog = require('internal-test-utils').assertLog; startTransition = React.startTransition; useOptimistic = React.useOptimistic; container = document.createElement('
{ "filepath": "packages/react-dom/src/__tests__/ReactStartTransitionMultipleRenderers-test.js", "language": "javascript", "file_size": 4160, "cut_index": 614, "middle_length": 229 }
ct.unstable_LegacyHidden mode={mode === 'hidden' ? 'unstable-defer-without-hiding' : mode}> {children} </React.unstable_LegacyHidden> </div> ); } it('should batch state when updating state twice', async () => { let componentState; let setState; function Component(...
['Commit']); expect(container.firstChild.textContent).toBe('0'); await act(() => { setState(1); setState(2); expect(componentState).toBe(0); expect(container.firstChild.textContent).toBe('0'); assertLog([]); });
return <div>{state}</div>; } const container = document.createElement('div'); const root = ReactDOMClient.createRoot(container); await act(() => { root.render(<Component />); }); assertLog(
{ "filepath": "packages/react-dom/src/__tests__/ReactUpdates-test.js", "language": "javascript", "file_size": 60632, "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'; let React; let ReactDOMServer; describe('quoteAttributeValueForBrowser', () => { beforeEach(() => { jest.resetModules(); React =...
onse).toMatch('<img data-attr="&quot;"/>'); }); it('single quote is escaped inside attributes', () => { const response = ReactDOMServer.renderToString(<img data-attr="'" />); expect(response).toMatch('<img data-attr="&#x27;"/>'); }); it('
attr="&" />); expect(response).toMatch('<img data-attr="&amp;"/>'); }); it('double quote is escaped inside attributes', () => { const response = ReactDOMServer.renderToString(<img data-attr={'"'} />); expect(resp
{ "filepath": "packages/react-dom/src/__tests__/quoteAttributeValueForBrowser-test.js", "language": "javascript", "file_size": 2305, "cut_index": 563, "middle_length": 229 }
the completed HTML. Don't suspend on the server. suspend = false; const finalHTML = ReactDOMServer.renderToString(<App />); const container = document.createElement('div'); container.innerHTML = finalHTML; const span = container.getElementsByTagName('span')[0]; // On the client we don't have...
nt).toBe(span); }); it('can hydrate siblings of a suspended component without errors', async () => { let suspend = false; let resolve; const promise = new Promise(resolvePromise => (resolve = resolvePromise)); function Child() {
); // Resolving the promise should continue hydration suspend = false; resolve(); await promise; await waitForAll([]); // We should now have hydrated with a ref on the existing span. expect(ref.curre
{ "filepath": "packages/react-dom/src/__tests__/ReactDOMServerPartialHydrationActivity-test.internal.js", "language": "javascript", "file_size": 81783, "cut_index": 3790, "middle_length": 229 }
ect(node.value).toBe('giraffe'); await act(() => { root.render(<select defaultValue="gorilla">{options}</select>); }); expect(node.value).toEqual('giraffe'); }); it('should not throw with `defaultValue` and without children', () => { const stub = <select defaultValue="dummy" />; expect...
>A giraffe!</option> <option value="gorilla">A gorilla!</option> </select> ); const container = document.createElement('div'); const root = ReactDOMClient.createRoot(container); await act(() => { root.render(el); })
}).not.toThrow(); }); it('should not control when using `defaultValue`', async () => { const el = ( <select defaultValue="giraffe"> <option value="monkey">A monkey!</option> <option value="giraffe"
{ "filepath": "packages/react-dom/src/__tests__/ReactDOMSelect-test.js", "language": "javascript", "file_size": 60710, "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 * @jest-environment ./scripts/jest/ReactDOMServerIntegrationEnvironment */ 'use strict'; const ReactDOMServerIntegrationUtils = require('./utils/ReactDOMSe...
rs. return { ReactDOMClient, ReactDOMServer, }; } const {resetModules, itRenders} = ReactDOMServerIntegrationUtils(initModules); // TODO: Run this in React Fire mode after we figure out the SSR behavior. const desc = disableInputAttributeSync
n initModules() { // Reset warning cache. jest.resetModules(); React = require('react'); ReactDOMClient = require('react-dom/client'); ReactDOMServer = require('react-dom/server'); // Make them available to the helpe
{ "filepath": "packages/react-dom/src/__tests__/ReactDOMServerIntegrationInput-test.js", "language": "javascript", "file_size": 3020, "cut_index": 563, "middle_length": 229 }
hing. await renderTextarea(<textarea defaultValue="gorilla" />, container, root); expect(node.value).toEqual('giraffe'); node.value = 'cat'; await renderTextarea(<textarea defaultValue="monkey" />, container, root); expect(node.value).toEqual('cat'); }); it('should display `defaultValue` of n...
eactDOMClient.createRoot(container); const node = await renderTextarea( <textarea defaultValue={0n} />, container, root, ); expect(node.value).toBe('0'); }); it('should display "false" for `defaultValue` of `false`', asy
ltValue={0} />, container, root, ); expect(node.value).toBe('0'); }); it('should display `defaultValue` of bigint 0', async () => { const container = document.createElement('div'); const root = R
{ "filepath": "packages/react-dom/src/__tests__/ReactDOMTextarea-test.js", "language": "javascript", "file_size": 35459, "cut_index": 2151, "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'; let React; let ReactDOMClient; let act; describe('ReactErrorBoundariesHooks', () => { beforeEach(() => { j...
eful'; } class ErrorHandler extends React.Component { state = {error: null}; componentDidCatch(error) { return this.setState({error}); } render() { if (this.state.error !== null) { return <p>Hand
ors are caught', async () => { function ErrorThrower() { React.useMemo(() => undefined, []); throw new Error('expected'); } function StatefulComponent() { React.useState(null); return ' | stat
{ "filepath": "packages/react-dom/src/__tests__/ReactErrorBoundariesHooks-test.internal.js", "language": "javascript", "file_size": 1629, "cut_index": 537, "middle_length": 229 }
st unmountConcurrent = _dom => { if (__DEV__) { act(() => { if (root !== null) { root.unmount(); root = null; } }); } else { if (root !== null) { root.unmount(); root = null; } } }; const rerenderConcurrent = el => { act(()...
ests(render, unmount, rerender) { describe('concurrent render', () => { beforeEach(() => { jest.resetModules(); React = require('react'); ReactDOMClient = require('react-dom/client'); Scheduler = require('scheduler'); ac
[]); return null; } // @gate __DEV__ it('does not warn', () => { root = ReactDOMClient.createRoot(document.createElement('div')); act(() => root.render(<App />)); }); }); }); function runActT
{ "filepath": "packages/react-dom/src/__tests__/ReactTestUtilsAct-test.js", "language": "javascript", "file_size": 22200, "cut_index": 1331, "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'; let React; let ReactDOMServer; describe('escapeTextForBrowser', () => { beforeEach(() => { jest.resetModules(); React = require(...
e).toMatch('<span>&quot;</span>'); }); it('single quote is escaped when passed as text content', () => { const response = ReactDOMServer.renderToString(<span>{"'"}</span>); expect(response).toMatch('<span>&#x27;</span>'); }); it('greater
'}</span>); expect(response).toMatch('<span>&amp;</span>'); }); it('double quote is escaped when passed as text content', () => { const response = ReactDOMServer.renderToString(<span>{'"'}</span>); expect(respons
{ "filepath": "packages/react-dom/src/__tests__/escapeTextForBrowser-test.js", "language": "javascript", "file_size": 2165, "cut_index": 563, "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'; const ReactDOMServerIntegrationUtils = require('./utils/ReactDOMServerIntegrationTestUtils'); let React; let ReactDO...
actDOMServerIntegrationTextarea', () => { beforeEach(() => { resetModules(); }); // textareas // --------- itRenders('a textarea with a value and an onChange', async render => { const e = await render(<textarea value="foo" onChange={() =
rver = require('react-dom/server'); // Make them available to the helpers. return { ReactDOMClient, ReactDOMServer, }; } const {resetModules, itRenders} = ReactDOMServerIntegrationUtils(initModules); describe('Re
{ "filepath": "packages/react-dom/src/__tests__/ReactDOMServerIntegrationTextarea-test.js", "language": "javascript", "file_size": 3524, "cut_index": 614, "middle_length": 229 }
MIT license found in the * LICENSE file in the root directory of this source tree. * * @emails react-core */ 'use strict'; let React; let ReactDOMClient; let act; let assertLog; let Scheduler; describe('ReactDOMSafariMicrotaskBug-test', () => { let container; let overrideQueueMicrotask; let flushFakeMicr...
=> { if (overrideQueueMicrotask) { fakeMicrotaskQueue.push(cb); } else { originalQueueMicrotask(cb); } }; flushFakeMicrotasks = () => { while (fakeMicrotaskQueue.length > 0) { const cb = fakeMicrotask
is added to the page. // https://github.com/facebook/react/issues/22459 const originalQueueMicrotask = queueMicrotask; overrideQueueMicrotask = false; const fakeMicrotaskQueue = []; global.queueMicrotask = cb
{ "filepath": "packages/react-dom/src/__tests__/ReactDOMSafariMicrotaskBug-test.js", "language": "javascript", "file_size": 3505, "cut_index": 614, "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'; const ReactDOMServerIntegrationUtils = require('./utils/ReactDOMServerIntegrationTestUtils'); let React; let ReactDO...
tDOMClient, ReactDOMServer, }; } const {resetModules, itRenders} = ReactDOMServerIntegrationUtils(initModules); function formatValue(val) { if (val === null) { return 'null'; } if (val === undefined) { return 'undefined'; } if (ty
/client'); ReactDOMServer = require('react-dom/server'); ReactFeatureFlags = require('shared/ReactFeatureFlags'); ReactFeatureFlags.disableLegacyContext = true; // Make them available to the helpers. return { Reac
{ "filepath": "packages/react-dom/src/__tests__/ReactDOMServerIntegrationLegacyContextDisabled-test.internal.js", "language": "javascript", "file_size": 4181, "cut_index": 614, "middle_length": 229 }
ct-core */ 'use strict'; let React; let ReactDOMClient; let act; let assertConsoleErrorDev; describe('ReactIdentity', () => { beforeEach(() => { jest.resetModules(); React = require('react'); ReactDOMClient = require('react-dom/client'); act = require('internal-test-utils').act; assertConsoleE...
t = ReactDOMClient.createRoot(container); await act(async () => { root.render(<Component />); }); const origChildren = Array.from(node.childNodes); await act(async () => { root.render(<Component swap={true} />); }); cons
<div ref={c => (node = c)}> <div key={props.swap ? 'banana' : 'apple'} /> <div key={props.swap ? 'apple' : 'banana'} /> </div> ); const container = document.createElement('div'); const roo
{ "filepath": "packages/react-dom/src/__tests__/ReactIdentity-test.js", "language": "javascript", "file_size": 8942, "cut_index": 716, "middle_length": 229 }
MIT license found in the * LICENSE file in the root directory of this source tree. * * @emails react-core */ // sanity tests to make sure act() works without a mocked scheduler let React; let ReactDOMClient; let act; let container; let yields; let prevActGlobal; function clearLog() { try { return yields; ...
global.IS_REACT_ACT_ENVIRONMENT = prevActGlobal; document.body.removeChild(container); }); // @gate __DEV__ test('can use act to flush effects', async () => { function App() { React.useEffect(() => { yields.push(100); }); return null
duler'); yields = []; React = require('react'); ReactDOMClient = require('react-dom/client'); act = React.act; container = document.createElement('div'); document.body.appendChild(container); }); afterEach(() => {
{ "filepath": "packages/react-dom/src/__tests__/ReactTestUtilsActUnmockedScheduler-test.js", "language": "javascript", "file_size": 3891, "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 * @jest-environment ./scripts/jest/ReactDOMServerIntegrationEnvironment */ 'use strict'; const ReactDOMServerIntegrationUtils = require('./utils/ReactDOMSe...
rs. return { ReactDOMClient, ReactDOMServer, }; } const {resetModules, itRenders} = ReactDOMServerIntegrationUtils(initModules); // TODO: Run this in React Fire mode after we figure out the SSR behavior. const desc = disableInputAttributeSync
n initModules() { // Reset warning cache. jest.resetModules(); React = require('react'); ReactDOMClient = require('react-dom/client'); ReactDOMServer = require('react-dom/server'); // Make them available to the helpe
{ "filepath": "packages/react-dom/src/__tests__/ReactDOMServerIntegrationCheckbox-test.js", "language": "javascript", "file_size": 2941, "cut_index": 563, "middle_length": 229 }
ViewTransition', () => { let container; beforeEach(() => { jest.resetModules(); React = require('react'); ReactDOMClient = require('react-dom/client'); Scheduler = require('scheduler'); act = require('internal-test-utils').act; assertLog = require('internal-test-utils').assertLog; Suspe...
resolveText(text) { const record = textCache.get(text); if (record === undefined) { const newRecord = { status: 'resolved', value: text, }; textCache.set(text, newRecord); } else if (record.status === 'pending'
able_SuspenseList; } container = document.createElement('div'); document.body.appendChild(container); textCache = new Map(); }); afterEach(() => { document.body.removeChild(container); }); function
{ "filepath": "packages/react-dom/src/__tests__/ReactDOMViewTransition-test.js", "language": "javascript", "file_size": 12672, "cut_index": 921, "middle_length": 229 }
import type {Writable} from 'stream'; import type {Thenable} from 'shared/ReactTypes'; import type {Duplex} from 'stream'; import {Readable} from 'stream'; import { createRequest, startWork, startFlowing, startFlowingDebug, stopFlowing, abort, resolveDebugMessage, closeDebugChannel, } from 'react-ser...
// Buffer-based string decoder helpers. The FB server environment does not // have TextDecoder, so we use Buffer.toString('utf8') instead. type BufferDecoder = {_pendingBytes: Array<Uint8Array>}; function createStringDecoder(): BufferDecoder { return
ver/src/ReactFlightReplyServer'; import { decodeAction, decodeFormState, } from 'react-server/src/ReactFlightActionServer'; export { registerServerReference, registerClientReference, } from '../ReactFlightFBReferences';
{ "filepath": "packages/react-flight-server-fb/src/server/ReactFlightDOMServerNode.js", "language": "javascript", "file_size": 10393, "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. * * @flow */ // ATTENTION // When adding new symbols to this file, // Please consider also adding to 'react-devtools-shared/src/backend/ReactSymbols' // The Symbol used to tag the...
const REACT_PROFILER_TYPE: symbol = Symbol.for('react.profiler'); export const REACT_CONSUMER_TYPE: symbol = Symbol.for('react.consumer'); export const REACT_CONTEXT_TYPE: symbol = Symbol.for('react.context'); export const REACT_FORWARD_REF_TYPE: symbol =
export const REACT_PORTAL_TYPE: symbol = Symbol.for('react.portal'); export const REACT_FRAGMENT_TYPE: symbol = Symbol.for('react.fragment'); export const REACT_STRICT_MODE_TYPE: symbol = Symbol.for('react.strict_mode'); export
{ "filepath": "packages/shared/ReactSymbols.js", "language": "javascript", "file_size": 2827, "cut_index": 563, "middle_length": 229 }
actPortal | ReactText | ReactFragment | ReactProvider<any> | ReactConsumer<any>; export type ReactEmpty = null | void | boolean; export type ReactFragment = ReactEmpty | Iterable<React$Node>; export type ReactNodeList = ReactEmpty | React$Node; export type ReactText = string | number; export type ReactProv...
eactNodeList, }, }; export type ReactContext<T> = { $$typeof: symbol | number, Consumer: ReactConsumerType<T>, Provider: ReactContext<T>, _currentValue: T, _currentValue2: T, _threadCount: number, // DEV only _currentRenderer?: Object |
= { $$typeof: symbol | number, _context: ReactContext<T>, }; export type ReactConsumer<T> = { $$typeof: symbol | number, type: ReactConsumerType<T>, key: ReactKey, ref: null, props: { children: (value: T) => R
{ "filepath": "packages/shared/ReactTypes.js", "language": "javascript", "file_size": 11932, "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 */ let didWarnAboutMessageChannel = false; let enqueueTaskImpl = null; export default function enqueueTask(task: () => void): void { if (enqu...
rsion of setImmediate, bypassing fake timers if any. enqueueTaskImpl = nodeRequire.call(module, 'timers').setImmediate; } catch (_err) { // we're in a browser // we can't use regular timers because they may still be faked // so
t requireString = ('require' + Math.random()).slice(0, 7); // $FlowFixMe[invalid-computed-prop] const nodeRequire = module && module[requireString]; // assuming we're in node, let's try to get node's // ve
{ "filepath": "packages/shared/enqueueTask.js", "language": "javascript", "file_size": 1879, "cut_index": 537, "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. * */ // Do not require this module directly! Use normal `invariant` calls with // template literal strings. The messages will be replaced with error codes // during ...
= '&args[]=' + encodeURIComponent(arguments[i]); } } return ( `Minified React error #${code}; visit ${url} for the full message or ` + 'use the non-minified dev environment for full errors and additional ' + 'helpful warnings.' ); }
(let i = 2; i < arguments.length; i++) { url +
{ "filepath": "packages/shared/formatProdErrorMessage.js", "language": "javascript", "file_size": 895, "cut_index": 547, "middle_length": 52 }
MIT license found in the * LICENSE file in the root directory of this source tree. * * @flow */ import type {LazyComponent} from 'react/src/ReactLazy'; import type {ReactContext, ReactConsumerType} from 'shared/ReactTypes'; import { REACT_CONTEXT_TYPE, REACT_CONSUMER_TYPE, REACT_FORWARD_REF_TYPE, REACT_F...
ponentNameFromFiber function getWrappedName( outerType: mixed, innerType: any, wrapperName: string, ): string { const displayName = (outerType: any).displayName; if (displayName) { return displayName; } const functionName = innerType.disp
KER_TYPE, REACT_VIEW_TRANSITION_TYPE, REACT_ACTIVITY_TYPE, } from 'shared/ReactSymbols'; import { enableTransitionTracing, enableViewTransition, } from './ReactFeatureFlags'; // Keep in sync with react-reconciler/getCom
{ "filepath": "packages/shared/getComponentNameFromType.js", "language": "javascript", "file_size": 3980, "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. * * @flow */ // Takes a format string (first argument to console) and returns a normalized // string that has the exact number of arguments as the args. T...
{ case 79 /* "O" */: case 99 /* "c" */: case 100 /* "d" */: case 102 /* "f" */: case 105 /* "i" */: case 111 /* "o" */: case 115 /* "s" */: { if (j < args.length) { // We have a matching argument
= firstArg; let normalizedString = ''; let last = 0; for (let i = 0; i < formatString.length - 1; i++) { if (formatString.charCodeAt(i) !== 37 /* "%" */) { continue; } switch (formatString.charCodeAt(++i))
{ "filepath": "packages/shared/normalizeConsoleFormat.js", "language": "javascript", "file_size": 1718, "cut_index": 537, "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 */ const reportGlobalError: (error: mixed) => void = typeof reportError === 'function' ? // In modern browsers, reportError will dispatch ...
-next-line react-internal/safe-string-coercion String(error.message) : // eslint-disable-next-line react-internal/safe-string-coercion String(error); const event = new window.ErrorEvent('error', {
'function' ) { // Browser Polyfill const message = typeof error === 'object' && error !== null && typeof error.message === 'string' ? // eslint-disable
{ "filepath": "packages/shared/reportGlobalError.js", "language": "javascript", "file_size": 1607, "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 is from './objectIs'; import hasOwnProperty from './hasOwnProperty'; /** * Performs equality by iterating through keys ...
} const keysA = Object.keys(objA); const keysB = Object.keys(objB); if (keysA.length !== keysB.length) { return false; } // Test for A's keys different from B. for (let i = 0; i < keysA.length; i++) { const currentKey = keysA[i];
llowEqual(objA: mixed, objB: mixed): boolean { if (is(objA, objB)) { return true; } if ( typeof objA !== 'object' || objA === null || typeof objB !== 'object' || objB === null ) { return false;
{ "filepath": "packages/shared/shallowEqual.js", "language": "javascript", "file_size": 1259, "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. * * @emails react-core */ 'use strict'; describe('ReactDOMFrameScheduling', () => { beforeEach(() => { jest.resetModules(); ...
al.window; try { // Simulate the Node environment: delete global.window; jest.resetModules(); expect(() => { require('react-dom'); }).not.toThrow(); } finally { global.window = prevWindow; } }); });
de environment', () => { const prevWindow = glob
{ "filepath": "packages/shared/__tests__/ReactDOMFrameScheduling-test.js", "language": "javascript", "file_size": 823, "cut_index": 514, "middle_length": 52 }
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'; let React; let ReactDOMClient; let act; describe('ReactError', () => { let globalErrorMock; beforeEach(() => { if (!__DEV__) { ...
rror; expect(typeof global.Error).toBe('function'); } jest.resetModules(); React = require('react'); ReactDOMClient = require('react-dom/client'); act = require('internal-test-utils').act; }); afterEach(() => { if (!__DEV
on't* want to decode // them. So we assert that the OriginalError exists, and temporarily // set the global Error object back to it. globalErrorMock = global.Error; global.Error = globalErrorMock.OriginalE
{ "filepath": "packages/shared/__tests__/ReactError-test.internal.js", "language": "javascript", "file_size": 2218, "cut_index": 563, "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. * * @emails react-core */ 'use strict'; let formatProdErrorMessage; describe('ReactErrorProd', () => { beforeEach(() => { jest.resetMo...
for full errors and additional helpful warnings.', ); expect(formatProdErrorMessage(20)).toEqual( 'Minified React error #20; visit ' + 'https://react.dev/errors/20' + ' for the full message or use the non-minified dev enviro
orMessage(124, 'foo', 'bar')).toEqual( 'Minified React error #124; visit ' + 'https://react.dev/errors/124?args[]=foo&args[]=bar' + ' for the full message or use the non-minified dev environment' + '
{ "filepath": "packages/shared/__tests__/ReactErrorProd-test.internal.js", "language": "javascript", "file_size": 1422, "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. * * @emails react-core */ 'use strict'; let normalizeConsoleFormat; describe('normalizeConsoleFormat', () => { beforeEach(() => { nor...
than args', async () => { expect( normalizeConsoleFormat('%s %O %o %f', [1, {}, 'foo'], 0), ).toMatchInlineSnapshot(`"%s %O %o %%f"`); }); it('normalize escape sequences', async () => { expect( normalizeConsoleFormat('hel%lo %s
ineSnapshot( `"%o %o %s"`, ); }); it('normalize extra args', async () => { expect( normalizeConsoleFormat('%f', [1, {}, 'foo'], 0), ).toMatchInlineSnapshot(`"%f %o %s"`); }); it('normalize fewer
{ "filepath": "packages/shared/__tests__/normalizeConsoleFormat-test.internal.js", "language": "javascript", "file_size": 1422, "cut_index": 524, "middle_length": 229 }
ffiliates. * * This source code is licensed under the MIT license found in the * LICENSE file in the root directory of this source tree. * * @flow strict */ // This fork provides www-specific feature flag values for // eslint-plugin-react-hooks without pulling in the full // ReactFeatureFlags.www.js fork. The fu...
rh_enableUseKeyedStateCompilerLint: boolean = true; export const eprh_enableVerboseNoSetStateInEffectCompilerLint: boolean = true; export const eprh_enableExhaustiveEffectDependenciesCompilerLint: | 'off' | 'all' | 'extra-only' | 'missing-only' = '
gs are needed by the ESLint plugin. export const ep
{ "filepath": "packages/shared/forks/ReactFeatureFlags.eslint-plugin.www.js", "language": "javascript", "file_size": 880, "cut_index": 559, "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 strict */ // In xplat, these flags are controlled by GKs. Because most GKs have some // population running in either mode, we shoul...
T__; export const enableObjectFiber = __VARIANT__; export const enableEagerAlternateStateNodeCleanup = __VARIANT__; export const passChildrenWhenCloningPersistedNodes = __VARIANT__; export const enableFragmentRefs = __VARIANT__; export const enableFragment
isn't supported for React Native flags yet. You can set the // flag here but it won't be set to `true` in any of our test runs. Need to // add a test configuration for React Native. export const alwaysThrottleRetries = __VARIAN
{ "filepath": "packages/shared/forks/ReactFeatureFlags.native-fb-dynamic.js", "language": "javascript", "file_size": 1287, "cut_index": 524, "middle_length": 229 }
MIT license found in the * LICENSE file in the root directory of this source tree. * * @flow */ import typeof * as FeatureFlagsType from 'shared/ReactFeatureFlags'; import typeof * as ExportsType from './ReactFeatureFlags.native-fb'; import typeof * as DynamicExportsType from './ReactFeatureFlags.native-fb-dynami...
alwaysThrottleRetries, enableEffectEventMutationPhase, enableObjectFiber, enableEagerAlternateStateNodeCleanup, passChildrenWhenCloningPersistedNodes, enableFragmentRefs, enableFragmentRefsScrollIntoView, enableFragmentRefsInstanceHandles,
lFeatureFlags'; const dynamicFlags: DynamicExportsType = (dynamicFlagsUntyped: any); // We destructure each value before re-exporting to avoid a dynamic look-up on // the exports object every time a flag is read. export const {
{ "filepath": "packages/shared/forks/ReactFeatureFlags.native-fb.js", "language": "javascript", "file_size": 4598, "cut_index": 614, "middle_length": 229 }
MIT license found in the * LICENSE file in the root directory of this source tree. * * @flow */ import typeof * as FeatureFlagsType from 'shared/ReactFeatureFlags'; import typeof * as ExportsType from './ReactFeatureFlags.native-oss'; // TODO: Align these flags with canary and delete this file once RN ships from...
disableLegacyContext: boolean = true; export const disableLegacyContextForFunctionComponents: boolean = true; export const disableLegacyMode: boolean = false; export const disableSchedulerTimeoutInWorkLoop: boolean = false; export const disableTextareaChil
const alwaysThrottleRetries: boolean = false; export const disableClientCache: boolean = true; export const disableCommentsAsDOMContainers: boolean = true; export const disableInputAttributeSyncing: boolean = false; export const
{ "filepath": "packages/shared/forks/ReactFeatureFlags.native-oss.js", "language": "javascript", "file_size": 4585, "cut_index": 614, "middle_length": 229 }
MIT license found in the * LICENSE file in the root directory of this source tree. * * @flow */ import typeof * as FeatureFlagsType from 'shared/ReactFeatureFlags'; import typeof * as ExportsType from './ReactFeatureFlags.test-renderer'; export const enableAsyncDebugInfo: boolean = true; export const enableSched...
acyCache: boolean = __EXPERIMENTAL__; export const enableAsyncIterableChildren: boolean = false; export const enableTaint: boolean = true; export const disableCommentsAsDOMContainers: boolean = true; export const disableInputAttributeSyncing: boolean = fal
hase: boolean = __PROFILE__; export const enableComponentPerformanceTrack: boolean = true; export const enablePerformanceIssueReporting: boolean = false; export const enableUpdaterTracking: boolean = false; export const enableLeg
{ "filepath": "packages/shared/forks/ReactFeatureFlags.test-renderer.js", "language": "javascript", "file_size": 4608, "cut_index": 614, "middle_length": 229 }
MIT license found in the * LICENSE file in the root directory of this source tree. * * @flow */ import typeof * as FeatureFlagsType from 'shared/ReactFeatureFlags'; import typeof * as ExportsType from './ReactFeatureFlags.test-renderer'; export const alwaysThrottleRetries = false; export const disableClientCache...
eAsyncIterableChildren = false; export const enableCPUSuspense = true; export const enableCreateEventHandleAPI = false; export const enableMoveBefore = false; export const enableFizzExternalRuntime = true; export const enableInfiniteRenderLoopDetection = f
unctionComponents = false; export const disableLegacyMode = false; export const disableSchedulerTimeoutInWorkLoop = false; export const disableTextareaChildren = false; export const enableAsyncDebugInfo = true; export const enabl
{ "filepath": "packages/shared/forks/ReactFeatureFlags.test-renderer.native-fb.js", "language": "javascript", "file_size": 3692, "cut_index": 614, "middle_length": 229 }
MIT license found in the * LICENSE file in the root directory of this source tree. * * @flow */ import typeof * as FeatureFlagsType from 'shared/ReactFeatureFlags'; import typeof * as ExportsType from './ReactFeatureFlags.test-renderer.www'; export const enableAsyncDebugInfo: boolean = true; export const enableS...
leLegacyCache: boolean = true; export const enableAsyncIterableChildren: boolean = false; export const enableTaint: boolean = true; export const disableCommentsAsDOMContainers: boolean = true; export const disableInputAttributeSyncing: boolean = false; exp
atePhase: boolean = __PROFILE__; export const enableComponentPerformanceTrack: boolean = false; export const enablePerformanceIssueReporting: boolean = false; export const enableUpdaterTracking: boolean = false; export const enab
{ "filepath": "packages/shared/forks/ReactFeatureFlags.test-renderer.www.js", "language": "javascript", "file_size": 4266, "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 strict */ // In www, these flags are controlled by GKs. Because most GKs have some // population running in either mode, we should run our tests that way, too, // // Use ...
jectFiber: boolean = __VARIANT__; export const enableRetryLaneExpiration: boolean = __VARIANT__; export const enableTransitionTracing: boolean = __VARIANT__; export const retryLaneExpirationMs = 5000; export const syncLaneExpirationMs = 250; export const t
rt const disableLegacyContextForFunctionComponents: boolean = __VARIANT__; export const disableSchedulerTimeoutInWorkLoop: boolean = __VARIANT__; export const enableNoCloningMemoCache: boolean = __VARIANT__; export const enableOb
{ "filepath": "packages/shared/forks/ReactFeatureFlags.www-dynamic.js", "language": "javascript", "file_size": 2220, "cut_index": 563, "middle_length": 229 }
MIT license found in the * LICENSE file in the root directory of this source tree. * * @flow */ import typeof * as FeatureFlagsType from 'shared/ReactFeatureFlags'; import typeof * as ExportsType from './ReactFeatureFlags.www'; import typeof * as DynamicFeatureFlags from './ReactFeatureFlags.www-dynamic'; // Re-...
etryLaneExpiration, enableTransitionTracing, retryLaneExpirationMs, syncLaneExpirationMs, transitionLaneExpirationMs, enableSuspenseyImages, enableViewTransition, enableScrollEndPolyfill, enableFragmentRefs, enableFragmentRefsScrollIntoVi
tionComponents, disableSchedulerTimeoutInWorkLoop, enableEffectEventMutationPhase, enableInfiniteRenderLoopDetection, enableInfiniteRenderLoopDetectionForceThrow, enableNoCloningMemoCache, enableObjectFiber, enableR
{ "filepath": "packages/shared/forks/ReactFeatureFlags.www.js", "language": "javascript", "file_size": 4498, "cut_index": 614, "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 {useSyncExternalStore} from 'use-sync-external-store/shim'; // Hook used for safely managing subscriptions in c...
entValue, // This function is passed an event handler to attach to the subscription. // It should return an unsubscribe function that removes the handler. subscribe, }: { getCurrentValue: () => Value, subscribe: (callback: Function) => () => voi
rapping the entire params object with useMemo() // or by wrapping the individual callbacks with useCallback(). export function useSubscription<Value>({ // (Synchronously) returns the current value of our subscription. getCurr
{ "filepath": "packages/use-subscription/src/useSubscription.js", "language": "javascript", "file_size": 1078, "cut_index": 515, "middle_length": 229 }
require('rxjs').BehaviorSubject; ReplaySubject = require('rxjs').ReplaySubject; const InternalTestUtils = require('internal-test-utils'); waitForAll = InternalTestUtils.waitForAll; waitForPaint = InternalTestUtils.waitForPaint; assertLog = InternalTestUtils.assertLog; waitFor = InternalTestUtil...
t('supports basic subscription pattern', async () => { function Child({value = 'default'}) { Scheduler.log(value); return null; } function Subscription({source}) { const value = useSubscription( React.useMemo(
return behaviorSubject; } function createReplaySubject(initialValue) { const replaySubject = new ReplaySubject(); if (initialValue) { replaySubject.next(initialValue); } return replaySubject; } i
{ "filepath": "packages/use-subscription/src/__tests__/useSubscription-test.js", "language": "javascript", "file_size": 17702, "cut_index": 1331, "middle_length": 229 }
MIT license found in the * LICENSE file in the root directory of this source tree. */ import {REACT_ELEMENT_TYPE, REACT_FRAGMENT_TYPE} from 'shared/ReactSymbols'; const {assertConsoleLogsCleared} = require('internal-test-utils/consoleMock'); import isArray from 'shared/isArray'; function captureAssertion(fn) { ...
root) { const Scheduler = root._Scheduler; const actualYields = Scheduler.unstable_clearLog(); if (actualYields.length !== 0) { const error = Error( 'Log of yielded values is not empty. ' + 'Call expect(ReactTestRenderer).unstable_t
nts to the original assertion in the // test file. try { fn(); } catch (error) { return { pass: false, message: () => error.message, }; } return {pass: true}; } function assertYieldsWereCleared(
{ "filepath": "packages/jest-react/src/JestReact.js", "language": "javascript", "file_size": 3931, "cut_index": 614, "middle_length": 229 }
MIT license found in the * LICENSE file in the root directory of this source tree. * * @flow */ import * as Scheduler from 'scheduler'; // Intentionally not named imports because Rollup would // use dynamic dispatch for CommonJS interop named imports. const { unstable_scheduleCallback: scheduleCallback, unst...
Circular, doubly-linked list let first: Entry<T> | null = null; let size: number = 0; let cleanUpIsScheduled: boolean = false; function scheduleCleanUp() { if (cleanUpIsScheduled === false && size > LIMIT) { // The cache size exceeds th
e: () => mixed): Entry<Object>, update(entry: Entry<T>, newValue: T): void, access(entry: Entry<T>): T, setLimit(newLimit: number): void, }; export function createLRU<T>(limit: number): LRU<T> { let LIMIT = limit; //
{ "filepath": "packages/react-cache/src/LRU.js", "language": "javascript", "file_size": 3881, "cut_index": 614, "middle_length": 229 }
MIT license found in the * LICENSE file in the root directory of this source tree. * * @flow */ import type {ReactContext, Thenable} from 'shared/ReactTypes'; import * as React from 'react'; import {createLRU} from './LRU'; interface Suspender { then(resolve: () => mixed, reject: () => mixed): mixed; } type...
NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE; function readContext(Context: ReactContext<mixed>) { const dispatcher = SharedInternals.H; if (dispatcher === null) { // This wasn't being minified but we're going to retire this package anyway. // es
gResult | ResolvedResult<V> | RejectedResult; type Resource<I, V> = { read(I): V, preload(I): void, ... }; const Pending = 0; const Resolved = 1; const Rejected = 2; const SharedInternals = React.__CLIENT_INTERNALS_DO_
{ "filepath": "packages/react-cache/src/ReactCacheOld.js", "language": "javascript", "file_size": 5077, "cut_index": 614, "middle_length": 229 }
sertLog; let waitForThrow; let act; let assertConsoleErrorDev; describe('ReactCache', () => { beforeEach(() => { jest.resetModules(); React = require('react'); Suspense = React.Suspense; ReactCache = require('react-cache'); createResource = ReactCache.unstable_createResource; ReactNoop = req...
act; TextResource = createResource( ([text, ms = 0]) => { let listeners = null; let status = 'pending'; let value = null; return { then(resolve, reject) { switch (status) { case
InternalTestUtils.assertLog; waitForThrow = InternalTestUtils.waitForThrow; waitForPaint = InternalTestUtils.waitForPaint; assertConsoleErrorDev = InternalTestUtils.assertConsoleErrorDev; act = InternalTestUtils.
{ "filepath": "packages/react-cache/src/__tests__/ReactCacheOld-test.internal.js", "language": "javascript", "file_size": 11568, "cut_index": 921, "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 */ export * from './ReactFiberConfigNoopHydration'; export * from './ReactFiberConfigNoopScopes'; export * from './ReactFiber...
r, hidden: boolean, context: HostContext, }; export type Instance = { type: string, id: number, parent: number, children: Array<Instance | TextInstance>, text: string | null, prop: any, hidden: boolean, context: HostContext, }; export
tence versions. export * from './ReactFiberConfigNoopNoMutation'; export * from './ReactFiberConfigNoopNoPersistence'; export type HostContext = Object; export type TextInstance = { text: string, id: number, parent: numbe
{ "filepath": "packages/react-noop-renderer/src/ReactFiberConfigNoop.js", "language": "javascript", "file_size": 1218, "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 */ // Renderers that don't support hydration // can re-export everything from this module. function shim(...args: any): empty { throw new Error( 'react-noop-render...
etails = shim; export const registerSuspenseInstanceRetry = shim; export const canHydrateFormStateMarker = shim; export const isFormStateMarkerMatching = shim; export const getNextHydratableSibling = shim; export const getNextHydratableSiblingAfterSingleto
= mixed; export type SuspenseInstance = mixed; export const supportsHydration = false; export const isSuspenseInstancePending = shim; export const isSuspenseInstanceFallback = shim; export const getSuspenseInstanceFallbackErrorD
{ "filepath": "packages/react-noop-renderer/src/ReactFiberConfigNoopHydration.js", "language": "javascript", "file_size": 2734, "cut_index": 563, "middle_length": 229 }
MIT license found in the * LICENSE file in the root directory of this source tree. * * @flow */ import type {ReactClientValue} from 'react-server/src/ReactFlightServer'; export type ServerReference<T: Function> = T & { $$typeof: symbol, $$id: string, $$bound: null | Array<ReactClientValue>, $$location?: ...
erverReference(reference: Object): boolean { return reference.$$typeof === SERVER_REFERENCE_TAG; } export function registerClientReference<T>( proxyImplementation: any, id: string, hblp: mixed, ): ClientReference<T> { return Object.definePropert
.client.reference'); const SERVER_REFERENCE_TAG = Symbol.for('react.server.reference'); export function isClientReference(reference: Object): boolean { return reference.$$typeof === CLIENT_REFERENCE_TAG; } export function isS
{ "filepath": "packages/react-flight-server-fb/src/ReactFlightFBReferences.js", "language": "javascript", "file_size": 3506, "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 */ // Renderers that don't support mutation // can re-export everything from this module. function shim(...args: any): empty { throw new Error( 'This entrypoint of...
export const commitMount = shim; export const commitUpdate = shim; export const insertBefore = shim; export const insertInContainerBefore = shim; export const removeChild = shim; export const removeChildFromContainer = shim; export const resetTextContent
supportsMutation = false; export const cloneMutableInstance = shim; export const cloneMutableTextInstance = shim; export const appendChild = shim; export const appendChildToContainer = shim; export const commitTextUpdate = shim;
{ "filepath": "packages/react-noop-renderer/src/ReactFiberConfigNoopNoMutation.js", "language": "javascript", "file_size": 2251, "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 */ // Renderers that don't support persistence // can re-export everything from this module. function shim(...args: any): empty { throw new Error( ...
e; export const cloneInstance = shim; export const createContainerChildSet = shim; export const appendChildToContainerChildSet = shim; export const finalizeContainerChildren = shim; export const replaceContainerChildren = shim; export const cloneHiddenInst
unsupported) export const supportsPersistence = fals
{ "filepath": "packages/react-noop-renderer/src/ReactFiberConfigNoopNoPersistence.js", "language": "javascript", "file_size": 913, "cut_index": 547, "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 */ // Renderers that don't support hydration // can re-export everything from this module. function shim(...args: any): empt...
shim; export const acquireResource = shim; export const releaseResource = shim; export const hydrateHoistable = shim; export const mountHoistable = shim; export const unmountHoistable = shim; export const createHoistableInstance = shim; export const prepar
stableRoot = mixed; export type Resource = mixed; // Resources (when unsupported) export const supportsResources = false; export const isHostHoistableType = shim; export const getHoistableRoot = shim; export const getResource =
{ "filepath": "packages/react-noop-renderer/src/ReactFiberConfigNoopResources.js", "language": "javascript", "file_size": 1151, "cut_index": 518, "middle_length": 229 }
import type { Thenable, FulfilledThenable, RejectedThenable, ReactDebugInfo, ReactIOInfo, ReactAsyncInfo, } from 'shared/ReactTypes'; import type {ModuleLoading} from 'react-client/src/ReactFlightClientConfig'; import {canUseDOM} from 'shared/ExecutionEnvironment'; export type ServerConsumerModuleMap = n...
xport function prepareDestinationForModule( moduleLoading: ModuleLoading, nonce: ?string, metadata: ClientReferenceMetadata, ) { prepareDestinationForModuleImpl(moduleLoading, metadata.$$hblp, nonce); } export function resolveClientReference<T>(
ClientReferenceMetadata = { $$typeof: symbol, $$id: string, $$hblp: mixed, }; // eslint-disable-next-line no-unused-vars export opaque type ClientReference<T> = { $$typeof: symbol, $$id: string, $$hblp: mixed, }; e
{ "filepath": "packages/react-flight-server-fb/src/client/ReactFlightClientConfigBundlerFB.js", "language": "javascript", "file_size": 7336, "cut_index": 716, "middle_length": 229 }
import type {Thenable} from 'shared/ReactTypes.js'; import type { DebugChannel, DebugChannelCallback, FindSourceMapURLCallback, Response as FlightResponse, } from 'react-client/src/ReactFlightClient'; import type {ReactServerValue} from 'react-client/src/ReactFlightReplyClient'; import { createResponse, ...
ightTemporaryReferences'; export {createTemporaryReferenceSet} from 'react-client/src/ReactFlightTemporaryReferences'; export type {TemporaryReferenceSet}; type CallServerCallback = <A, T>(string, args: A) => Promise<T>; export type Options = { callS
} from 'react-client/src/ReactFlightReplyClient'; export { createServerReference, registerServerReference, } from 'react-client/src/ReactFlightReplyClient'; import type {TemporaryReferenceSet} from 'react-client/src/ReactFl
{ "filepath": "packages/react-flight-server-fb/src/client/ReactFlightDOMClientBrowser.js", "language": "javascript", "file_size": 8132, "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 {ReactComponentInfo} from 'shared/ReactTypes'; import {describeBuiltInComponentFrame} from 'shared/ReactComponentStackFrame'; i...
le // on the regular stack that's currently executing. However, if there is no owner at all, then // there's no stack frame so we add the name of the root component to the stack to know which // component is currently executing. if (!compon
''; } try { let info = ''; // The owner stack of the current component will be where it was created, i.e. inside its owner. // There's no actual name of the currently executing component. Instead, that is availab
{ "filepath": "packages/shared/ReactComponentInfoStack.js", "language": "javascript", "file_size": 1689, "cut_index": 537, "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. * * Shared logic for Fragment Ref operations for DOM and Fabric configs * * @flow */ import type {Fiber} from 'react-reconciler/src/ReactInternalTypes'; import {getNextSiblingHo...
$FlowFixMe[incompatible-use] Fabric PublicInstance is opaque // $FlowFixMe[prop-missing] const parentResult = parentHostInstance.compareDocumentPosition(otherNode); result = parentResult; if (parentHostInstance === otherNode) { result = Node.DO
nstance, otherNode: TPublicInstance, getPublicInstance: (fiber: Fiber) => TPublicInstance, ): number { let result; // If the fragment has no children, we can use the parent and // siblings to determine a position. //
{ "filepath": "packages/shared/ReactDOMFragmentRefShared.js", "language": "javascript", "file_size": 2092, "cut_index": 563, "middle_length": 229 }
----------------------------------------------------------------- // None // ----------------------------------------------------------------------------- // Killswitch // // Flags that exist solely to turn off a change in case it causes a regression // when it rolls out to prod. We should remove these as soon as pos...
------- // Need to remove didTimeout argument from Scheduler before landing export const disableSchedulerTimeoutInWorkLoop: boolean = false; // ----------------------------------------------------------------------------- // Slated for removal in the fut
erate effort) // // Flags that can be probably deleted or landed, but might require extra effort // like migrating internal callers or performance testing. // ----------------------------------------------------------------------
{ "filepath": "packages/shared/ReactFeatureFlags.js", "language": "javascript", "file_size": 10781, "cut_index": 921, "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 ReactSharedInternals from 'shared/ReactSharedInternals'; let lastResetTime = 0; let getCurrentTime: () => number | ...
ow = getCurrentTime(); const timeSinceLastReset = now - lastResetTime; if (timeSinceLastReset > 1000) { ReactSharedInternals.recentlyCreatedOwnerStacks = 0; lastResetTime = now; } } else { // These errors should never make it
ocalPerformance = performance; getCurrentTime = () => localPerformance.now(); } else { const localDate = Date; getCurrentTime = () => localDate.now(); } export function resetOwnerStackLimit() { if (__DEV__) { const n
{ "filepath": "packages/shared/ReactOwnerStackReset.js", "language": "javascript", "file_size": 1263, "cut_index": 524, "middle_length": 229 }
import type {LazyComponent} from 'react/src/ReactLazy'; import isArray from 'shared/isArray'; import getPrototypeOf from 'shared/getPrototypeOf'; import {enableViewTransition} from 'shared/ReactFeatureFlags'; // Used for DEV messages to keep track of which parent rendered some props, // in case they error. export ...
(getPrototypeOf(object)) { return false; } const names = Object.getOwnPropertyNames(object); for (let i = 0; i < names.length; i++) { if (!(names[i] in ObjectPrototype)) { return false; } } return true; } export function isGett
{ return false; } const ObjectPrototype = Object.prototype; if (object === ObjectPrototype) { return true; } // It might be an object from a different Realm which is // still just a plain simple object. if
{ "filepath": "packages/shared/ReactSerializationErrors.js", "language": "javascript", "file_size": 9698, "cut_index": 921, "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 type {ReactNodeList} from 'shared/ReactTypes'; import {version, renderToStringImpl} from './ReactDOMLegacyServerImpl'; ...
Suspense boundary. If you intended to have the server wait for the suspended component please switch to "renderToPipeableStream" which supports Suspense on the server', ); } function renderToStaticMarkup( children: ReactNodeList, options?: ServerOpt
options, false, 'The server used "renderToString" which does not support Suspense. If you intended for this Suspense boundary to render the fallback content on the server consider throwing an Error somewhere within the
{ "filepath": "packages/react-dom/src/server/ReactDOMLegacyServerNode.js", "language": "javascript", "file_size": 1384, "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 */ export function defaultOnDefaultTransitionIndicator(): void | (() => void) { if (typeof navigation !== 'object') { // If the Navigation API is not available, the...
} } function handleNavigateComplete() { if (pendingResolve !== null) { // If this was not our navigation completing, we were probably cancelled. // We'll start a new one below. pendingResolve(); pendingResolve = null;
event.info === 'react-transition') { event.intercept({ handler() { return new Promise(resolve => (pendingResolve = resolve)); }, focusReset: 'manual', scroll: 'manual', });
{ "filepath": "packages/react-dom/src/client/ReactDOMDefaultTransitionIndicator.js", "language": "javascript", "file_size": 2830, "cut_index": 563, "middle_length": 229 }
tInternalTypes'; import type { Container, PublicInstance, } from 'react-dom-bindings/src/client/ReactFiberConfigDOM'; import { createRoot as createRootImpl, hydrateRoot as hydrateRootImpl, } from './ReactDOMRoot'; import { disableLegacyMode, disableCommentsAsDOMContainers, } from 'shared/ReactFeatureFlag...
ontainer'; import { DOCUMENT_NODE, ELEMENT_NODE, COMMENT_NODE, } from 'react-dom-bindings/src/client/HTMLNodeType'; import { batchedUpdates, createContainer, createHydrationContainer, findHostInstanceWithNoPortals, updateContainer, updat
} from 'react-dom-bindings/src/client/ReactDOMComponentTree'; import {listenToAllSupportedEvents} from 'react-dom-bindings/src/events/DOMPluginEventSystem'; import {isValidContainer} from 'react-dom-bindings/src/client/ReactDOMC
{ "filepath": "packages/react-dom/src/client/ReactDOMRootFB.js", "language": "javascript", "file_size": 14965, "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'; // TODO: can we express this test with only public API? const getNodeForCharacterOffset = require('react-dom-bindings/src/client/getNodeF...
doc.close(); return doc; } // Check getNodeForCharacterOffset return value matches expected result. function expectNodeOffset(result, textContent, nodeOffset) { expect(result.node.textContent).toBe(textContent); expect(result.offset).toBe(nodeOffset
node; } function getTestDocument(markup) { const doc = document.implementation.createHTMLDocument(''); doc.open(); doc.write( markup || '<!doctype html><html><meta charset=utf-8><title>test doc</title>', );
{ "filepath": "packages/react-dom/src/client/__tests__/getNodeForCharacterOffset-test.js", "language": "javascript", "file_size": 2336, "cut_index": 563, "middle_length": 229 }
use strict'; async function insertNodesAndExecuteScripts( source: Document | Element, target: Node, CSPnonce: string | null, ) { const ownerDocument = target.ownerDocument || target; // We need to remove the script content for any scripts that would not run based on CSP // We restore the script content af...
); script.textContent = ''; } } } let lastChild = null; while (source.firstChild) { const node = source.firstChild; if (lastChild === node) { throw new Error('Infinite loop.'); } lastChild = node; if (node
i < scripts.length; i++) { const script = scripts[i]; if ( !script.hasAttribute('src') && script.getAttribute('nonce') !== CSPnonce ) { badNonceScriptNodes.set(script, script.textContent
{ "filepath": "packages/react-dom/src/test-utils/FizzTestUtils.js", "language": "javascript", "file_size": 5875, "cut_index": 716, "middle_length": 229 }
; function checkDCE() { /* global __REACT_DEVTOOLS_GLOBAL_HOOK__ */ if ( typeof __REACT_DEVTOOLS_GLOBAL_HOOK__ === 'undefined' || typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE !== 'function' ) { return; } if (process.env.NODE_ENV !== 'production') { // This branch is unreachable because this...
Verify that the code above has been dead code eliminated (DCE'd). __REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE(checkDCE); } catch (err) { // DevTools shouldn't crash React, no matter what. // We should still report in case we break this code.
. // Don't change the message. React DevTools relies on it. Also make sure // this message doesn't occur elsewhere in this function, or it will cause // a false positive. throw new Error('^_^'); } try { //
{ "filepath": "packages/react-dom/npm/index.js", "language": "javascript", "file_size": 1359, "cut_index": 524, "middle_length": 229 }
; function checkDCE() { /* global __REACT_DEVTOOLS_GLOBAL_HOOK__ */ if ( typeof __REACT_DEVTOOLS_GLOBAL_HOOK__ === 'undefined' || typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE !== 'function' ) { return; } if (process.env.NODE_ENV !== 'production') { // This branch is unreachable because this...
Verify that the code above has been dead code eliminated (DCE'd). __REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE(checkDCE); } catch (err) { // DevTools shouldn't crash React, no matter what. // We should still report in case we break this code.
. // Don't change the message. React DevTools relies on it. Also make sure // this message doesn't occur elsewhere in this function, or it will cause // a false positive. throw new Error('^_^'); } try { //
{ "filepath": "packages/react-dom/npm/profiling.js", "language": "javascript", "file_size": 1378, "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 */ // Custom implementation of FlightServerConfigDOM. // Resource hint dispatching is a no-op since we handle resource loadin...
tCode = $Keys<TypeMap>; export type HintModel<T: HintCode> = TypeMap[T]; export type Hints = Set<string>; export function createHints(): Hints { return new Set(); } export opaque type FormatContext = number; export function createRootFormatContext():
ring], 'L': [string, string] | [string, string, any], 'm': string | [string, any], 'S': string | [string, string] | [string, string | 0, any], 'X': string | [string, any], 'M': string | [string, any], } export type Hin
{ "filepath": "packages/react-flight-server-fb/src/server/ReactFlightServerConfigDOMFB.js", "language": "javascript", "file_size": 1184, "cut_index": 518, "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 type {ReactClientValue} from 'react-server/src/ReactFlightServer'; import type { ClientReference, ServerReference, }...
): ClientReferenceKey { return reference.$$id; } export function resolveClientReferenceMetadata<T>( config: ClientManifest, clientReference: ClientReference<T>, ): ClientReferenceMetadata { return clientReference; } export function getServerRefe
tadata = ClientReference<any>; export type ClientReferenceKey = string; export {isClientReference, isServerReference} from '../ReactFlightFBReferences'; export function getClientReferenceKey( reference: ClientReference<any>,
{ "filepath": "packages/react-flight-server-fb/src/server/ReactFlightServerConfigFBBundler.js", "language": "javascript", "file_size": 1503, "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 */ // Helpers to patch console.logs to avoid logging during side-effect free // replaying on render function. This currently only patches the object // lazily which won't...
/no-production-logging */ prevLog = console.log; prevInfo = console.info; prevWarn = console.warn; prevError = console.error; prevGroup = console.group; prevGroupCollapsed = console.groupCollapsed; prevGroupEnd = c
prevGroupCollapsed; let prevGroupEnd; function disabledLog() {} disabledLog.__reactDisabledLog = true; export function disableLogs(): void { if (__DEV__) { if (disabledDepth === 0) { /* eslint-disable react-internal
{ "filepath": "packages/shared/ConsolePatchingDev.js", "language": "javascript", "file_size": 2420, "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 */ export function getIODescription(value: mixed): string { if (!__DEV__) { return ''; } try { switch (typeof value) { case 'function': return...
ring-coercion return String(value.message); } else if (typeof value.url === 'string') { return value.url; } else if (typeof value.href === 'string') { return value.href; } else if (typeof value.src ===
uld ideally be a name that // describes the arguments requested. if (value === null) { return ''; } else if (value instanceof Error) { // eslint-disable-next-line react-internal/safe-st
{ "filepath": "packages/shared/ReactIODescription.js", "language": "javascript", "file_size": 2714, "cut_index": 563, "middle_length": 229 }
ols'; import getComponentNameFromType from './getComponentNameFromType'; const EMPTY_ARRAY = 0; const COMPLEX_ARRAY = 1; const PRIMITIVE_ARRAY = 2; // Primitive values only that are accepted by JSON.stringify const ENTRIES_ARRAY = 3; // Tuple arrays of string and value (like Headers, Map, etc) // Showing wider object...
) { // Key value tuple if (kind !== EMPTY_ARRAY && kind !== ENTRIES_ARRAY) { return COMPLEX_ARRAY; } kind = ENTRIES_ARRAY; } else { return COMPLEX_ARRAY; } } else if (typeof value === 'fun
gth && i < OBJECT_WIDTH_LIMIT; i++) { const value = array[i]; if (typeof value === 'object' && value !== null) { if ( isArray(value) && value.length === 2 && typeof value[0] === 'string'
{ "filepath": "packages/shared/ReactPerformanceTrackProperties.js", "language": "javascript", "file_size": 15179, "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. * * @flow */ import {createRoot, hydrateRoot} from './ReactDOMRoot'; import { injectIntoDevTools, findHostInstance, } from 'react-reconciler/src/ReactFiberReconciler'; import ...
ype Map.prototype == null || typeof Map.prototype.forEach !== 'function' || typeof Set !== 'function' || // $FlowFixMe[prop-missing] Flow incorrectly thinks Set has no prototype Set.prototype == null || typeof Set.prototype.clear !=
rsion} from '../shared/ensureCorrectIsomorphicReactVersion'; ensureCorrectIsomorphicReactVersion(); if (__DEV__) { if ( typeof Map !== 'function' || // $FlowFixMe[prop-missing] Flow incorrectly thinks Map has no protot
{ "filepath": "packages/react-dom/src/client/ReactDOMClient.js", "language": "javascript", "file_size": 2642, "cut_index": 563, "middle_length": 229 }
(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'; const React = require('react'); const ReactDOMClient = require('react-dom/client'); const act = require(...
root = ReactDOMClient.createRoot(container); await act(() => { root.render( <div dangerouslySetInnerHTML={{__html: '<h1>Hello</h1>'}} />, ); }); expect(container.firstChild.innerHTML).toBe('<h1>Hello</h1>');
tainer = document.createElement('div'); const
{ "filepath": "packages/react-dom/src/client/__tests__/dangerouslySetInnerHTML-test.js", "language": "javascript", "file_size": 851, "cut_index": 529, "middle_length": 52 }
; function checkDCE() { /* global __REACT_DEVTOOLS_GLOBAL_HOOK__ */ if ( typeof __REACT_DEVTOOLS_GLOBAL_HOOK__ === 'undefined' || typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE !== 'function' ) { return; } if (process.env.NODE_ENV !== 'production') { // This branch is unreachable because this...
Verify that the code above has been dead code eliminated (DCE'd). __REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE(checkDCE); } catch (err) { // DevTools shouldn't crash React, no matter what. // We should still report in case we break this code.
. // Don't change the message. React DevTools relies on it. Also make sure // this message doesn't occur elsewhere in this function, or it will cause // a false positive. throw new Error('^_^'); } try { //
{ "filepath": "packages/react-dom/npm/client.js", "language": "javascript", "file_size": 1373, "cut_index": 524, "middle_length": 229 }
// Fork of ReactServerStreamConfigNode for the FB Flight server. // Avoids importing from 'util' and 'crypto'. Uses the global TextEncoder // and stubs createFastHash. import type {Writable} from 'stream'; import type {TextEncoder as TextEncoderType} from 'util'; interface MightBeFlushable { flush?: () => void; } ...
don't have any more data to send right now. // Flush whatever is in the buffer to the wire. if (typeof destination.flush === 'function') { // By convention the Zlib streams provide a flush function for this purpose. // For Express, compression
heduleWork(callback: () => void) { setImmediate(callback); } export function scheduleMicrotask(callback: () => void) { Promise.resolve().then(callback); } export function flushBuffered(destination: Destination) { // If we
{ "filepath": "packages/react-flight-server-fb/src/ReactServerStreamConfigFB.js", "language": "javascript", "file_size": 6869, "cut_index": 716, "middle_length": 229 }
/* * The `'' + value` pattern (used in perf-sensitive code) throws for Symbol * and Temporal.* types. See https://github.com/facebook/react/pull/22064. * * The functions in this module will throw an easier-to-understand, * easier-to-debug exception with a clear errors message message explaining the * problem. (In...
oStringTag && (value: any)[Symbol.toStringTag]) || (value: any).constructor.name || 'Object'; // $FlowFixMe[incompatible-return] return type; } } // $FlowFixMe[incompatible-return] only called in DEV, so void return is not possible.
typeName(value: mixed): string { if (__DEV__) { // toStringTag is needed for namespaced types like Temporal.Instant const hasToStringTag = typeof Symbol === 'function' && Symbol.toStringTag; const type = (hasT
{ "filepath": "packages/shared/CheckStringCoercion.js", "language": "javascript", "file_size": 6201, "cut_index": 716, "middle_length": 229 }
; import {formatOwnerStack} from './ReactOwnerStackFrames'; let prefix; let suffix; export function describeBuiltInComponentFrame(name: string): string { if (prefix === undefined) { // Extract the VM specific prefix used by each line. try { throw Error(); } catch (x) { const match = x.stack....
efix + name + suffix; } export function describeDebugInfoFrame( name: string, env: ?string, location: ?Error, ): string { if (location != null) { // If we have a location, it's the child's owner stack. Treat the bottom most frame as // the
C/Spidermonkey x.stack.indexOf('@') > -1 ? '@unknown:0:0' : // Other ''; } } // We use the prefix to ensure our stacks line up with native stack frames. return '\n' + pr
{ "filepath": "packages/shared/ReactComponentStackFrame.js", "language": "javascript", "file_size": 12322, "cut_index": 921, "middle_length": 229 }
rom 'react-dom-bindings/src/client/ReactDOMContainer'; import {queueExplicitHydrationTarget} from 'react-dom-bindings/src/events/ReactDOMEventReplaying'; import {REACT_ELEMENT_TYPE} from 'shared/ReactSymbols'; import { disableCommentsAsDOMContainers, enableDefaultTransitionIndicator, } from 'shared/ReactFeatureFlag...
errorInfo: { +componentStack?: ?string, +errorBoundary?: ?component(...props: any), }, ) => void, onRecoverableError?: ( error: mixed, errorInfo: {+componentStack?: ?string}, ) => void, onDefaultTransitionIndicator?: ()
an, unstable_transitionCallbacks?: TransitionTracingCallbacks, identifierPrefix?: string, onUncaughtError?: ( error: mixed, errorInfo: {+componentStack?: ?string}, ) => void, onCaughtError?: ( error: mixed,
{ "filepath": "packages/react-dom/src/client/ReactDOMRoot.js", "language": "javascript", "file_size": 12238, "cut_index": 921, "middle_length": 229 }
; function checkDCE() { /* global __REACT_DEVTOOLS_GLOBAL_HOOK__ */ if ( typeof __REACT_DEVTOOLS_GLOBAL_HOOK__ === 'undefined' || typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE !== 'function' ) { return; } if (process.env.NODE_ENV !== 'production') { // This branch is unreachable because this...
Verify that the code above has been dead code eliminated (DCE'd). __REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE(checkDCE); } catch (err) { // DevTools shouldn't crash React, no matter what. // We should still report in case we break this code.
. // Don't change the message. React DevTools relies on it. Also make sure // this message doesn't occur elsewhere in this function, or it will cause // a false positive. throw new Error('^_^'); } try { //
{ "filepath": "packages/react-dom/npm/unstable_testing.js", "language": "javascript", "file_size": 1393, "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 DefaultPrepareStackTrace from 'shared/DefaultPrepareStackTrace'; export function formatOwnerStack(error: Error): string ...
x !== -1) { // Pop the JSX frame. stack = stack.slice(idx + 1); } idx = stack.indexOf('react_stack_bottom_frame'); if (idx !== -1) { idx = stack.lastIndexOf('\n', idx); } if (idx !== -1) { // Cut off everything after the bottom fr
if (stack.startsWith('Error: react-stack-top-frame\n')) { // V8's default formatting prefixes with the error message which we // don't want/need. stack = stack.slice(29); } let idx = stack.indexOf('\n'); if (id
{ "filepath": "packages/shared/ReactOwnerStackFrames.js", "language": "javascript", "file_size": 1341, "cut_index": 524, "middle_length": 229 }
; let ttObject2; beforeEach(() => { jest.resetModules(); container = document.createElement('div'); const fakeTTObjects = new Set(); window.trustedTypes = { isHTML: function (value) { if (this !== window.trustedTypes) { throw new Error(this); } return fakeTTO...
ects.add(ttObject1); fakeTTObjects.add(ttObject2); }); afterEach(() => { delete window.trustedTypes; }); it('should not stringify trusted values for dangerouslySetInnerHTML', async () => { const innerHTMLDescriptor = Object.getOwnProp
tConsoleErrorDev} = require('internal-test-utils')); ttObject1 = { toString() { return '<b>Hi</b>'; }, }; ttObject2 = { toString() { return '<b>Bye</b>'; }, }; fakeTTObj
{ "filepath": "packages/react-dom/src/client/__tests__/trustedTypes-test.internal.js", "language": "javascript", "file_size": 9310, "cut_index": 921, "middle_length": 229 }
import type {ReactNodeList} from 'shared/ReactTypes'; import {disableLegacyMode} from 'shared/ReactFeatureFlags'; import {isValidContainer} from 'react-dom-bindings/src/client/ReactDOMContainer'; import {createEventHandle} from 'react-dom-bindings/src/client/ReactDOMEventHandle'; import {runWithPriority} from 'react-d...
DOM} from 'shared/ExecutionEnvironment'; import ReactVersion from 'shared/ReactVersion'; import {ensureCorrectIsomorphicReactVersion} from '../shared/ensureCorrectIsomorphicReactVersion'; ensureCorrectIsomorphicReactVersion(); import { getInstanceFromN
readyRendering, isAlreadyRendering, injectIntoDevTools, findHostInstance, } from 'react-reconciler/src/ReactFiberReconciler'; import {createPortal as createPortalImpl} from 'react-reconciler/src/ReactPortal'; import {canUse
{ "filepath": "packages/react-dom/src/client/ReactDOMClientFB.js", "language": "javascript", "file_size": 5851, "cut_index": 716, "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 */ // Renderers that don't support mutation // can re-export everything from this module. function shim(...args: any): a...
ted) export const supportsSingletons = false; export const resolveSingletonInstance = shim; export const acquireSingletonInstance = shim; export const releaseSingletonInstance = shim; export const isHostSingletonType = shim; export const isSingletonScope =
(when unsuppor
{ "filepath": "packages/react-noop-renderer/src/ReactFiberConfigNoopSingletons.js", "language": "javascript", "file_size": 791, "cut_index": 514, "middle_length": 14 }
, 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 */ // Renderers that don't support persistence // can re-export everything from this module. function shim(...args: any): empty { throw new Error( ...
oneInstance = shim; export const createContainerChildSet = shim; export const appendChildToContainerChildSet = shim; export const finalizeContainerChildren = shim; export const replaceContainerChildren = shim; export const cloneHiddenInstance = shim; expor
t const supportsPersistence = false; export const cl
{ "filepath": "packages/react-reconciler/src/ReactFiberConfigWithNoPersistence.js", "language": "javascript", "file_size": 895, "cut_index": 547, "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 */ // Renderers that don't support hydration // can re-export everything from this module. function shim(...args: any): empt...
shim; export const acquireResource = shim; export const releaseResource = shim; export const hydrateHoistable = shim; export const mountHoistable = shim; export const unmountHoistable = shim; export const createHoistableInstance = shim; export const prepa
istableRoot = mixed; export type Resource = mixed; // Resources (when unsupported) export const supportsResources = false; export const isHostHoistableType = shim; export const getHoistableRoot = shim; export const getResource =
{ "filepath": "packages/react-reconciler/src/ReactFiberConfigWithNoResources.js", "language": "javascript", "file_size": 1152, "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 */ // Renderers that don't support mutation // can re-export everything from this module. function shim(...args: any): a...
rted) export const supportsSingletons = false; export const resolveSingletonInstance = shim; export const acquireSingletonInstance = shim; export const releaseSingletonInstance = shim; export const isHostSingletonType = shim; export const isSingletonScope
(when unsuppo
{ "filepath": "packages/react-reconciler/src/ReactFiberConfigWithNoSingletons.js", "language": "javascript", "file_size": 792, "cut_index": 514, "middle_length": 14 }