@samitouri / QOS-React-2 / commits / b365ee2816

[Fire] Remove unused React fire fork (#16046)

Dominic Gannaway committed Jul 3, 2019 at 11:05 UTC b365ee2816896ea9f01c1f65e65d403955762f8f
12 files changed +1 -1035
.circleci/config.yml
-14
@@ -94,17 +94,6 @@ jobs:
94 - *run_yarn
95 - run: yarn test-prod --maxWorkers=2
96
97 - test_source_fire:
98 - docker: *docker
99 - environment: *environment
100 -
101 - steps:
102 - - checkout
103 - - *restore_yarn_cache
104 - - *run_yarn
105 - - run: yarn test-fire --maxWorkers=2
106 - - run: yarn test-fire-prod --maxWorkers=2
107 -
97 test_coverage:
98 docker: *docker
99 environment: *environment
@@ -237,9 +226,6 @@ workflows:
226 - test_source_persistent:
227 requires:
228 - setup
240 - - test_source_fire:
241 - requires:
242 - - setup
229 - build:
230 requires:
231 - setup
fixtures/unstable-fire/index.html deleted
-14
@@ -1,14 +0,0 @@
1 -<html>
2 - <body>
3 - <script src="../../build/node_modules/react/umd/react.development.js"></script>
4 - <script src="../../build/node_modules/react-dom/umd/react-dom-unstable-fire.development.js"></script>
5 - <script src="https://unpkg.com/babel-standalone@6/babel.js"></script>
6 - <div id="container"></div>
7 - <script type="text/babel">
8 - ReactFire.render(
9 - <h1>Hello World!</h1>,
10 - document.getElementById('container')
11 - );
12 - </script>
13 - </body>
14 -</html>
\ No newline at end of file
package.json
-2
@@ -104,9 +104,7 @@
104 "debug-test": "cross-env NODE_ENV=development node --inspect-brk node_modules/.bin/jest --config ./scripts/jest/config.source.js --runInBand",
105 "test": "cross-env NODE_ENV=development jest --config ./scripts/jest/config.source.js",
106 "test-persistent": "cross-env NODE_ENV=development jest --config ./scripts/jest/config.source-persistent.js",
107 - "test-fire": "cross-env NODE_ENV=development jest --config ./scripts/jest/config.source-fire.js",
107 "test-prod": "cross-env NODE_ENV=production jest --config ./scripts/jest/config.source.js",
109 - "test-fire-prod": "cross-env NODE_ENV=production jest --config ./scripts/jest/config.source-fire.js",
108 "test-prod-build": "yarn test-build-prod",
109 "test-build": "cross-env NODE_ENV=development jest --config ./scripts/jest/config.build.js",
110 "test-build-prod": "cross-env NODE_ENV=production jest --config ./scripts/jest/config.build.js",
packages/react-dom/src/fire/ReactFire.js deleted
-919
@@ -1,919 +0,0 @@
1 -/**
2 - * Copyright (c) Facebook, Inc. and its affiliates.
3 - *
4 - * This source code is licensed under the MIT license found in the
5 - * LICENSE file in the root directory of this source tree.
6 - *
7 - * @flow
8 - */
9 -
10 -// This file is copy paste from ReactDOM with adjusted paths
11 -// and a different host config import (react-reconciler/inline.fire).
12 -// TODO: real implementation.
13 -// console.log('Hello from Fire entry point.');
14 -
15 -import type {ReactNodeList} from 'shared/ReactTypes';
16 -import type {RootTag} from 'shared/ReactRootTags';
17 -// TODO: This type is shared between the reconciler and ReactDOM, but will
18 -// eventually be lifted out to the renderer.
19 -import type {
20 - FiberRoot,
21 - Batch as FiberRootBatch,
22 -} from 'react-reconciler/src/ReactFiberRoot';
23 -
24 -import '../shared/checkReact';
25 -import '../client/ReactDOMClientInjection';
26 -
27 -import {
28 - computeUniqueAsyncExpiration,
29 - findHostInstanceWithNoPortals,
30 - updateContainerAtExpirationTime,
31 - flushRoot,
32 - createContainer,
33 - updateContainer,
34 - batchedEventUpdates,
35 - batchedUpdates,
36 - unbatchedUpdates,
37 - discreteUpdates,
38 - flushDiscreteUpdates,
39 - flushSync,
40 - flushControlled,
41 - injectIntoDevTools,
42 - getPublicRootInstance,
43 - findHostInstance,
44 - findHostInstanceWithWarning,
45 - flushPassiveEffects,
46 - IsThisRendererActing,
47 -} from 'react-reconciler/inline.fire';
48 -import {createPortal as createPortalImpl} from 'shared/ReactPortal';
49 -import {canUseDOM} from 'shared/ExecutionEnvironment';
50 -import {setBatchingImplementation} from 'events/ReactGenericBatching';
51 -import {
52 - setRestoreImplementation,
53 - enqueueStateRestore,
54 - restoreStateIfNeeded,
55 -} from 'events/ReactControlledComponent';
56 -import {injection as EventPluginHubInjection} from 'events/EventPluginHub';
57 -
58 -import {runEventsInBatch} from 'events/EventBatching';
59 -import {eventNameDispatchConfigs} from 'events/EventPluginRegistry';
60 -import {
61 - accumulateTwoPhaseDispatches,
62 - accumulateDirectDispatches,
63 -} from 'events/EventPropagators';
64 -import {LegacyRoot, ConcurrentRoot, BatchedRoot} from 'shared/ReactRootTags';
65 -import {has as hasInstance} from 'shared/ReactInstanceMap';
66 -import ReactVersion from 'shared/ReactVersion';
67 -import ReactSharedInternals from 'shared/ReactSharedInternals';
68 -import getComponentName from 'shared/getComponentName';
69 -import invariant from 'shared/invariant';
70 -import lowPriorityWarning from 'shared/lowPriorityWarning';
71 -import warningWithoutStack from 'shared/warningWithoutStack';
72 -import {enableStableConcurrentModeAPIs} from 'shared/ReactFeatureFlags';
73 -
74 -import {
75 - getInstanceFromNode,
76 - getNodeFromInstance,
77 - getFiberCurrentPropsFromNode,
78 - getClosestInstanceFromNode,
79 -} from '../client/ReactDOMComponentTree';
80 -import {restoreControlledState} from '../client/ReactDOMComponent';
81 -import {dispatchEvent} from '../events/ReactDOMEventListener';
82 -import {
83 - ELEMENT_NODE,
84 - COMMENT_NODE,
85 - DOCUMENT_NODE,
86 - DOCUMENT_FRAGMENT_NODE,
87 -} from '../shared/HTMLNodeType';
88 -import {ROOT_ATTRIBUTE_NAME} from '../shared/DOMProperty';
89 -
90 -const ReactCurrentOwner = ReactSharedInternals.ReactCurrentOwner;
91 -
92 -let topLevelUpdateWarnings;
93 -let warnOnInvalidCallback;
94 -let didWarnAboutUnstableCreatePortal = false;
95 -
96 -if (__DEV__) {
97 - if (
98 - typeof Map !== 'function' ||
99 - // $FlowIssue Flow incorrectly thinks Map has no prototype
100 - Map.prototype == null ||
101 - typeof Map.prototype.forEach !== 'function' ||
102 - typeof Set !== 'function' ||
103 - // $FlowIssue Flow incorrectly thinks Set has no prototype
104 - Set.prototype == null ||
105 - typeof Set.prototype.clear !== 'function' ||
106 - typeof Set.prototype.forEach !== 'function'
107 - ) {
108 - warningWithoutStack(
109 - false,
110 - 'React depends on Map and Set built-in types. Make sure that you load a ' +
111 - 'polyfill in older browsers. https://fb.me/react-polyfills',
112 - );
113 - }
114 -
115 - topLevelUpdateWarnings = (container: DOMContainer) => {
116 - if (container._reactRootContainer && container.nodeType !== COMMENT_NODE) {
117 - const hostInstance = findHostInstanceWithNoPortals(
118 - container._reactRootContainer._internalRoot.current,
119 - );
120 - if (hostInstance) {
121 - warningWithoutStack(
122 - hostInstance.parentNode === container,
123 - 'render(...): It looks like the React-rendered content of this ' +
124 - 'container was removed without using React. This is not ' +
125 - 'supported and will cause errors. Instead, call ' +
126 - 'ReactDOM.unmountComponentAtNode to empty a container.',
127 - );
128 - }
129 - }
130 -
131 - const isRootRenderedBySomeReact = !!container._reactRootContainer;
132 - const rootEl = getReactRootElementInContainer(container);
133 - const hasNonRootReactChild = !!(rootEl && getInstanceFromNode(rootEl));
134 -
135 - warningWithoutStack(
136 - !hasNonRootReactChild || isRootRenderedBySomeReact,
137 - 'render(...): Replacing React-rendered children with a new root ' +
138 - 'component. If you intended to update the children of this node, ' +
139 - 'you should instead have the existing children update their state ' +
140 - 'and render the new components instead of calling ReactDOM.render.',
141 - );
142 -
143 - warningWithoutStack(
144 - container.nodeType !== ELEMENT_NODE ||
145 - !((container: any): Element).tagName ||
146 - ((container: any): Element).tagName.toUpperCase() !== 'BODY',
147 - 'render(): Rendering components directly into document.body is ' +
148 - 'discouraged, since its children are often manipulated by third-party ' +
149 - 'scripts and browser extensions. This may lead to subtle ' +
150 - 'reconciliation issues. Try rendering into a container element created ' +
151 - 'for your app.',
152 - );
153 - };
154 -
155 - warnOnInvalidCallback = function(callback: mixed, callerName: string) {
156 - warningWithoutStack(
157 - callback === null || typeof callback === 'function',
158 - '%s(...): Expected the last optional `callback` argument to be a ' +
159 - 'function. Instead received: %s.',
160 - callerName,
161 - callback,
162 - );
163 - };
164 -}
165 -
166 -setRestoreImplementation(restoreControlledState);
167 -
168 -export type DOMContainer =
169 - | (Element & {
170 - _reactRootContainer: ?(_ReactRoot | _ReactSyncRoot),
171 - _reactHasBeenPassedToCreateRootDEV: ?boolean,
172 - })
173 - | (Document & {
174 - _reactRootContainer: ?(_ReactRoot | _ReactSyncRoot),
175 - _reactHasBeenPassedToCreateRootDEV: ?boolean,
176 - });
177 -
178 -type Batch = FiberRootBatch & {
179 - render(children: ReactNodeList): Work,
180 - then(onComplete: () => mixed): void,
181 - commit(): void,
182 -
183 - // The ReactRoot constructor is hoisted but the prototype methods are not. If
184 - // we move ReactRoot to be above ReactBatch, the inverse error occurs.
185 - // $FlowFixMe Hoisting issue.
186 - _root: _ReactRoot | _ReactSyncRoot,
187 - _hasChildren: boolean,
188 - _children: ReactNodeList,
189 -
190 - _callbacks: Array<() => mixed> | null,
191 - _didComplete: boolean,
192 -};
193 -
194 -type _ReactSyncRoot = {
195 - render(children: ReactNodeList, callback: ?() => mixed): Work,
196 - unmount(callback: ?() => mixed): Work,
197 -
198 - _internalRoot: FiberRoot,
199 -};
200 -
201 -type _ReactRoot = _ReactSyncRoot & {
202 - createBatch(): Batch,
203 -};
204 -
205 -function ReactBatch(root: _ReactRoot | _ReactSyncRoot) {
206 - const expirationTime = computeUniqueAsyncExpiration();
207 - this._expirationTime = expirationTime;
208 - this._root = root;
209 - this._next = null;
210 - this._callbacks = null;
211 - this._didComplete = false;
212 - this._hasChildren = false;
213 - this._children = null;
214 - this._defer = true;
215 -}
216 -ReactBatch.prototype.render = function(children: ReactNodeList) {
217 - invariant(
218 - this._defer,
219 - 'batch.render: Cannot render a batch that already committed.',
220 - );
221 - this._hasChildren = true;
222 - this._children = children;
223 - const internalRoot = this._root._internalRoot;
224 - const expirationTime = this._expirationTime;
225 - const work = new ReactWork();
226 - updateContainerAtExpirationTime(
227 - children,
228 - internalRoot,
229 - null,
230 - expirationTime,
231 - null,
232 - work._onCommit,
233 - );
234 - return work;
235 -};
236 -ReactBatch.prototype.then = function(onComplete: () => mixed) {
237 - if (this._didComplete) {
238 - onComplete();
239 - return;
240 - }
241 - let callbacks = this._callbacks;
242 - if (callbacks === null) {
243 - callbacks = this._callbacks = [];
244 - }
245 - callbacks.push(onComplete);
246 -};
247 -ReactBatch.prototype.commit = function() {
248 - const internalRoot = this._root._internalRoot;
249 - let firstBatch = internalRoot.firstBatch;
250 - invariant(
251 - this._defer && firstBatch !== null,
252 - 'batch.commit: Cannot commit a batch multiple times.',
253 - );
254 -
255 - if (!this._hasChildren) {
256 - // This batch is empty. Return.
257 - this._next = null;
258 - this._defer = false;
259 - return;
260 - }
261 -
262 - let expirationTime = this._expirationTime;
263 -
264 - // Ensure this is the first batch in the list.
265 - if (firstBatch !== this) {
266 - // This batch is not the earliest batch. We need to move it to the front.
267 - // Update its expiration time to be the expiration time of the earliest
268 - // batch, so that we can flush it without flushing the other batches.
269 - if (this._hasChildren) {
270 - expirationTime = this._expirationTime = firstBatch._expirationTime;
271 - // Rendering this batch again ensures its children will be the final state
272 - // when we flush (updates are processed in insertion order: last
273 - // update wins).
274 - // TODO: This forces a restart. Should we print a warning?
275 - this.render(this._children);
276 - }
277 -
278 - // Remove the batch from the list.
279 - let previous = null;
280 - let batch = firstBatch;
281 - while (batch !== this) {
282 - previous = batch;
283 - batch = batch._next;
284 - }
285 - invariant(
286 - previous !== null,
287 - 'batch.commit: Cannot commit a batch multiple times.',
288 - );
289 - previous._next = batch._next;
290 -
291 - // Add it to the front.
292 - this._next = firstBatch;
293 - firstBatch = internalRoot.firstBatch = this;
294 - }
295 -
296 - // Synchronously flush all the work up to this batch's expiration time.
297 - this._defer = false;
298 - flushRoot(internalRoot, expirationTime);
299 -
300 - // Pop the batch from the list.
301 - const next = this._next;
302 - this._next = null;
303 - firstBatch = internalRoot.firstBatch = next;
304 -
305 - // Append the next earliest batch's children to the update queue.
306 - if (firstBatch !== null && firstBatch._hasChildren) {
307 - firstBatch.render(firstBatch._children);
308 - }
309 -};
310 -ReactBatch.prototype._onComplete = function() {
311 - if (this._didComplete) {
312 - return;
313 - }
314 - this._didComplete = true;
315 - const callbacks = this._callbacks;
316 - if (callbacks === null) {
317 - return;
318 - }
319 - // TODO: Error handling.
320 - for (let i = 0; i < callbacks.length; i++) {
321 - const callback = callbacks[i];
322 - callback();
323 - }
324 -};
325 -
326 -type Work = {
327 - then(onCommit: () => mixed): void,
328 - _onCommit: () => void,
329 - _callbacks: Array<() => mixed> | null,
330 - _didCommit: boolean,
331 -};
332 -
333 -function ReactWork() {
334 - this._callbacks = null;
335 - this._didCommit = false;
336 - // TODO: Avoid need to bind by replacing callbacks in the update queue with
337 - // list of Work objects.
338 - this._onCommit = this._onCommit.bind(this);
339 -}
340 -ReactWork.prototype.then = function(onCommit: () => mixed): void {
341 - if (this._didCommit) {
342 - onCommit();
343 - return;
344 - }
345 - let callbacks = this._callbacks;
346 - if (callbacks === null) {
347 - callbacks = this._callbacks = [];
348 - }
349 - callbacks.push(onCommit);
350 -};
351 -ReactWork.prototype._onCommit = function(): void {
352 - if (this._didCommit) {
353 - return;
354 - }
355 - this._didCommit = true;
356 - const callbacks = this._callbacks;
357 - if (callbacks === null) {
358 - return;
359 - }
360 - // TODO: Error handling.
361 - for (let i = 0; i < callbacks.length; i++) {
362 - const callback = callbacks[i];
363 - invariant(
364 - typeof callback === 'function',
365 - 'Invalid argument passed as callback. Expected a function. Instead ' +
366 - 'received: %s',
367 - callback,
368 - );
369 - callback();
370 - }
371 -};
372 -
373 -function ReactSyncRoot(
374 - container: DOMContainer,
375 - tag: RootTag,
376 - hydrate: boolean,
377 -) {
378 - // Tag is either LegacyRoot or Concurrent Root
379 - const root = createContainer(container, tag, hydrate);
380 - this._internalRoot = root;
381 -}
382 -
383 -function ReactRoot(container: DOMContainer, hydrate: boolean) {
384 - const root = createContainer(container, ConcurrentRoot, hydrate);
385 - this._internalRoot = root;
386 -}
387 -
388 -ReactRoot.prototype.render = ReactSyncRoot.prototype.render = function(
389 - children: ReactNodeList,
390 - callback: ?() => mixed,
391 -): Work {
392 - const root = this._internalRoot;
393 - const work = new ReactWork();
394 - callback = callback === undefined ? null : callback;
395 - if (__DEV__) {
396 - warnOnInvalidCallback(callback, 'render');
397 - }
398 - if (callback !== null) {
399 - work.then(callback);
400 - }
401 - updateContainer(children, root, null, work._onCommit);
402 - return work;
403 -};
404 -
405 -ReactRoot.prototype.unmount = ReactSyncRoot.prototype.unmount = function(
406 - callback: ?() => mixed,
407 -): Work {
408 - const root = this._internalRoot;
409 - const work = new ReactWork();
410 - callback = callback === undefined ? null : callback;
411 - if (__DEV__) {
412 - warnOnInvalidCallback(callback, 'render');
413 - }
414 - if (callback !== null) {
415 - work.then(callback);
416 - }
417 - updateContainer(null, root, null, work._onCommit);
418 - return work;
419 -};
420 -
421 -// Sync roots cannot create batches. Only concurrent ones.
422 -ReactRoot.prototype.createBatch = function(): Batch {
423 - const batch = new ReactBatch(this);
424 - const expirationTime = batch._expirationTime;
425 -
426 - const internalRoot = this._internalRoot;
427 - const firstBatch = internalRoot.firstBatch;
428 - if (firstBatch === null) {
429 - internalRoot.firstBatch = batch;
430 - batch._next = null;
431 - } else {
432 - // Insert sorted by expiration time then insertion order
433 - let insertAfter = null;
434 - let insertBefore = firstBatch;
435 - while (
436 - insertBefore !== null &&
437 - insertBefore._expirationTime >= expirationTime
438 - ) {
439 - insertAfter = insertBefore;
440 - insertBefore = insertBefore._next;
441 - }
442 - batch._next = insertBefore;
443 - if (insertAfter !== null) {
444 - insertAfter._next = batch;
445 - }
446 - }
447 -
448 - return batch;
449 -};
450 -
451 -/**
452 - * True if the supplied DOM node is a valid node element.
453 - *
454 - * @param {?DOMElement} node The candidate DOM node.
455 - * @return {boolean} True if the DOM is a valid DOM node.
456 - * @internal
457 - */
458 -function isValidContainer(node) {
459 - return !!(
460 - node &&
461 - (node.nodeType === ELEMENT_NODE ||
462 - node.nodeType === DOCUMENT_NODE ||
463 - node.nodeType === DOCUMENT_FRAGMENT_NODE ||
464 - (node.nodeType === COMMENT_NODE &&
465 - node.nodeValue === ' react-mount-point-unstable '))
466 - );
467 -}
468 -
469 -function getReactRootElementInContainer(container: any) {
470 - if (!container) {
471 - return null;
472 - }
473 -
474 - if (container.nodeType === DOCUMENT_NODE) {
475 - return container.documentElement;
476 - } else {
477 - return container.firstChild;
478 - }
479 -}
480 -
481 -function shouldHydrateDueToLegacyHeuristic(container) {
482 - const rootElement = getReactRootElementInContainer(container);
483 - return !!(
484 - rootElement &&
485 - rootElement.nodeType === ELEMENT_NODE &&
486 - rootElement.hasAttribute(ROOT_ATTRIBUTE_NAME)
487 - );
488 -}
489 -
490 -setBatchingImplementation(
491 - batchedUpdates,
492 - discreteUpdates,
493 - flushDiscreteUpdates,
494 - batchedEventUpdates,
495 -);
496 -
497 -let warnedAboutHydrateAPI = false;
498 -
499 -function legacyCreateRootFromDOMContainer(
500 - container: DOMContainer,
501 - forceHydrate: boolean,
502 -): _ReactSyncRoot {
503 - const shouldHydrate =
504 - forceHydrate || shouldHydrateDueToLegacyHeuristic(container);
505 - // First clear any existing content.
506 - if (!shouldHydrate) {
507 - let warned = false;
508 - let rootSibling;
509 - while ((rootSibling = container.lastChild)) {
510 - if (__DEV__) {
511 - if (
512 - !warned &&
513 - rootSibling.nodeType === ELEMENT_NODE &&
514 - (rootSibling: any).hasAttribute(ROOT_ATTRIBUTE_NAME)
515 - ) {
516 - warned = true;
517 - warningWithoutStack(
518 - false,
519 - 'render(): Target node has markup rendered by React, but there ' +
520 - 'are unrelated nodes as well. This is most commonly caused by ' +
521 - 'white-space inserted around server-rendered markup.',
522 - );
523 - }
524 - }
525 - container.removeChild(rootSibling);
526 - }
527 - }
528 - if (__DEV__) {
529 - if (shouldHydrate && !forceHydrate && !warnedAboutHydrateAPI) {
530 - warnedAboutHydrateAPI = true;
531 - lowPriorityWarning(
532 - false,
533 - 'render(): Calling ReactDOM.render() to hydrate server-rendered markup ' +
534 - 'will stop working in React v17. Replace the ReactDOM.render() call ' +
535 - 'with ReactDOM.hydrate() if you want React to attach to the server HTML.',
536 - );
537 - }
538 - }
539 -
540 - // Legacy roots are not batched.
541 - return new ReactSyncRoot(container, LegacyRoot, shouldHydrate);
542 -}
543 -
544 -function legacyRenderSubtreeIntoContainer(
545 - parentComponent: ?React$Component<any, any>,
546 - children: ReactNodeList,
547 - container: DOMContainer,
548 - forceHydrate: boolean,
549 - callback: ?Function,
550 -) {
551 - if (__DEV__) {
552 - topLevelUpdateWarnings(container);
553 - warnOnInvalidCallback(callback === undefined ? null : callback, 'render');
554 - }
555 -
556 - // TODO: Without `any` type, Flow says "Property cannot be accessed on any
557 - // member of intersection type." Whyyyyyy.
558 - let root: _ReactSyncRoot = (container._reactRootContainer: any);
559 - let fiberRoot;
560 - if (!root) {
561 - // Initial mount
562 - root = container._reactRootContainer = legacyCreateRootFromDOMContainer(
563 - container,
564 - forceHydrate,
565 - );
566 - fiberRoot = root._internalRoot;
567 - if (typeof callback === 'function') {
568 - const originalCallback = callback;
569 - callback = function() {
570 - const instance = getPublicRootInstance(fiberRoot);
571 - originalCallback.call(instance);
572 - };
573 - }
574 - // Initial mount should not be batched.
575 - unbatchedUpdates(() => {
576 - updateContainer(children, fiberRoot, parentComponent, callback);
577 - });
578 - } else {
579 - fiberRoot = root._internalRoot;
580 - if (typeof callback === 'function') {
581 - const originalCallback = callback;
582 - callback = function() {
583 - const instance = getPublicRootInstance(fiberRoot);
584 - originalCallback.call(instance);
585 - };
586 - }
587 - // Update
588 - updateContainer(children, fiberRoot, parentComponent, callback);
589 - }
590 - return getPublicRootInstance(fiberRoot);
591 -}
592 -
593 -function createPortal(
594 - children: ReactNodeList,
595 - container: DOMContainer,
596 - key: ?string = null,
597 -) {
598 - invariant(
599 - isValidContainer(container),
600 - 'Target container is not a DOM element.',
601 - );
602 - // TODO: pass ReactDOM portal implementation as third argument
603 - return createPortalImpl(children, container, null, key);
604 -}
605 -
606 -const ReactDOM: Object = {
607 - createPortal,
608 -
609 - findDOMNode(
610 - componentOrElement: Element | ?React$Component<any, any>,
611 - ): null | Element | Text {
612 - if (__DEV__) {
613 - let owner = (ReactCurrentOwner.current: any);
614 - if (owner !== null && owner.stateNode !== null) {
615 - const warnedAboutRefsInRender =
616 - owner.stateNode._warnedAboutRefsInRender;
617 - warningWithoutStack(
618 - warnedAboutRefsInRender,
619 - '%s is accessing findDOMNode inside its render(). ' +
620 - 'render() should be a pure function of props and state. It should ' +
621 - 'never access something that requires stale data from the previous ' +
622 - 'render, such as refs. Move this logic to componentDidMount and ' +
623 - 'componentDidUpdate instead.',
624 - getComponentName(owner.type) || 'A component',
625 - );
626 - owner.stateNode._warnedAboutRefsInRender = true;
627 - }
628 - }
629 - if (componentOrElement == null) {
630 - return null;
631 - }
632 - if ((componentOrElement: any).nodeType === ELEMENT_NODE) {
633 - return (componentOrElement: any);
634 - }
635 - if (__DEV__) {
636 - return findHostInstanceWithWarning(componentOrElement, 'findDOMNode');
637 - }
638 - return findHostInstance(componentOrElement);
639 - },
640 -
641 - hydrate(element: React$Node, container: DOMContainer, callback: ?Function) {
642 - invariant(
643 - isValidContainer(container),
644 - 'Target container is not a DOM element.',
645 - );
646 - if (__DEV__) {
647 - warningWithoutStack(
648 - !container._reactHasBeenPassedToCreateRootDEV,
649 - 'You are calling ReactDOM.hydrate() on a container that was previously ' +
650 - 'passed to ReactDOM.%s(). This is not supported. ' +
651 - 'Did you mean to call createRoot(container, {hydrate: true}).render(element)?',
652 - enableStableConcurrentModeAPIs ? 'createRoot' : 'unstable_createRoot',
653 - );
654 - }
655 - // TODO: throw or warn if we couldn't hydrate?
656 - return legacyRenderSubtreeIntoContainer(
657 - null,
658 - element,
659 - container,
660 - true,
661 - callback,
662 - );
663 - },
664 -
665 - render(
666 - element: React$Element<any>,
667 - container: DOMContainer,
668 - callback: ?Function,
669 - ) {
670 - invariant(
671 - isValidContainer(container),
672 - 'Target container is not a DOM element.',
673 - );
674 - if (__DEV__) {
675 - warningWithoutStack(
676 - !container._reactHasBeenPassedToCreateRootDEV,
677 - 'You are calling ReactDOM.render() on a container that was previously ' +
678 - 'passed to ReactDOM.%s(). This is not supported. ' +
679 - 'Did you mean to call root.render(element)?',
680 - enableStableConcurrentModeAPIs ? 'createRoot' : 'unstable_createRoot',
681 - );
682 - }
683 - return legacyRenderSubtreeIntoContainer(
684 - null,
685 - element,
686 - container,
687 - false,
688 - callback,
689 - );
690 - },
691 -
692 - unstable_renderSubtreeIntoContainer(
693 - parentComponent: React$Component<any, any>,
694 - element: React$Element<any>,
695 - containerNode: DOMContainer,
696 - callback: ?Function,
697 - ) {
698 - invariant(
699 - isValidContainer(containerNode),
700 - 'Target container is not a DOM element.',
701 - );
702 - invariant(
703 - parentComponent != null && hasInstance(parentComponent),
704 - 'parentComponent must be a valid React Component',
705 - );
706 - return legacyRenderSubtreeIntoContainer(
707 - parentComponent,
708 - element,
709 - containerNode,
710 - false,
711 - callback,
712 - );
713 - },
714 -
715 - unmountComponentAtNode(container: DOMContainer) {
716 - invariant(
717 - isValidContainer(container),
718 - 'unmountComponentAtNode(...): Target container is not a DOM element.',
719 - );
720 -
721 - if (__DEV__) {
722 - warningWithoutStack(
723 - !container._reactHasBeenPassedToCreateRootDEV,
724 - 'You are calling ReactDOM.unmountComponentAtNode() on a container that was previously ' +
725 - 'passed to ReactDOM.%s(). This is not supported. Did you mean to call root.unmount()?',
726 - enableStableConcurrentModeAPIs ? 'createRoot' : 'unstable_createRoot',
727 - );
728 - }
729 -
730 - if (container._reactRootContainer) {
731 - if (__DEV__) {
732 - const rootEl = getReactRootElementInContainer(container);
733 - const renderedByDifferentReact = rootEl && !getInstanceFromNode(rootEl);
734 - warningWithoutStack(
735 - !renderedByDifferentReact,
736 - "unmountComponentAtNode(): The node you're attempting to unmount " +
737 - 'was rendered by another copy of React.',
738 - );
739 - }
740 -
741 - // Unmount should not be batched.
742 - unbatchedUpdates(() => {
743 - legacyRenderSubtreeIntoContainer(null, null, container, false, () => {
744 - container._reactRootContainer = null;
745 - });
746 - });
747 - // If you call unmountComponentAtNode twice in quick succession, you'll
748 - // get `true` twice. That's probably fine?
749 - return true;
750 - } else {
751 - if (__DEV__) {
752 - const rootEl = getReactRootElementInContainer(container);
753 - const hasNonRootReactChild = !!(rootEl && getInstanceFromNode(rootEl));
754 -
755 - // Check if the container itself is a React root node.
756 - const isContainerReactRoot =
757 - container.nodeType === ELEMENT_NODE &&
758 - isValidContainer(container.parentNode) &&
759 - !!container.parentNode._reactRootContainer;
760 -
761 - warningWithoutStack(
762 - !hasNonRootReactChild,
763 - "unmountComponentAtNode(): The node you're attempting to unmount " +
764 - 'was rendered by React and is not a top-level container. %s',
765 - isContainerReactRoot
766 - ? 'You may have accidentally passed in a React root node instead ' +
767 - 'of its container.'
768 - : 'Instead, have the parent component update its state and ' +
769 - 'rerender in order to remove this component.',
770 - );
771 - }
772 -
773 - return false;
774 - }
775 - },
776 -
777 - // Temporary alias since we already shipped React 16 RC with it.
778 - // TODO: remove in React 17.
779 - unstable_createPortal(...args) {
780 - if (!didWarnAboutUnstableCreatePortal) {
781 - didWarnAboutUnstableCreatePortal = true;
782 - lowPriorityWarning(
783 - false,
784 - 'The ReactDOM.unstable_createPortal() alias has been deprecated, ' +
785 - 'and will be removed in React 17+. Update your code to use ' +
786 - 'ReactDOM.createPortal() instead. It has the exact same API, ' +
787 - 'but without the "unstable_" prefix.',
788 - );
789 - }
790 - return createPortal(...args);
791 - },
792 -
793 - unstable_batchedUpdates: batchedUpdates,
794 -
795 - // TODO remove this legacy method, unstable_discreteUpdates replaces it
796 - unstable_interactiveUpdates: (fn, a, b, c) => {
797 - flushDiscreteUpdates();
798 - return discreteUpdates(fn, a, b, c);
799 - },
800 -
801 - unstable_discreteUpdates: discreteUpdates,
802 - unstable_flushDiscreteUpdates: flushDiscreteUpdates,
803 -
804 - flushSync: flushSync,
805 -
806 - unstable_createRoot: createRoot,
807 - unstable_createSyncRoot: createSyncRoot,
808 - unstable_flushControlled: flushControlled,
809 -
810 - __SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED: {
811 - // Keep in sync with ReactDOMUnstableNativeDependencies.js
812 - // ReactTestUtils.js, and ReactTestUtilsAct.js. This is an array for better minification.
813 - Events: [
814 - getInstanceFromNode,
815 - getNodeFromInstance,
816 - getFiberCurrentPropsFromNode,
817 - EventPluginHubInjection.injectEventPluginsByName,
818 - eventNameDispatchConfigs,
819 - accumulateTwoPhaseDispatches,
820 - accumulateDirectDispatches,
821 - enqueueStateRestore,
822 - restoreStateIfNeeded,
823 - dispatchEvent,
824 - runEventsInBatch,
825 - flushPassiveEffects,
826 - IsThisRendererActing,
827 - ],
828 - },
829 -};
830 -
831 -type RootOptions = {
832 - hydrate?: boolean,
833 -};
834 -
835 -function createRoot(
836 - container: DOMContainer,
837 - options?: RootOptions,
838 -): _ReactRoot {
839 - const functionName = enableStableConcurrentModeAPIs
840 - ? 'createRoot'
841 - : 'unstable_createRoot';
842 - invariant(
843 - isValidContainer(container),
844 - '%s(...): Target container is not a DOM element.',
845 - functionName,
846 - );
847 - warnIfReactDOMContainerInDEV(container);
848 - const hydrate = options != null && options.hydrate === true;
849 - return new ReactRoot(container, hydrate);
850 -}
851 -
852 -function createSyncRoot(
853 - container: DOMContainer,
854 - options?: RootOptions,
855 -): _ReactSyncRoot {
856 - const functionName = enableStableConcurrentModeAPIs
857 - ? 'createRoot'
858 - : 'unstable_createRoot';
859 - invariant(
860 - isValidContainer(container),
861 - '%s(...): Target container is not a DOM element.',
862 - functionName,
863 - );
864 - warnIfReactDOMContainerInDEV(container);
865 - const hydrate = options != null && options.hydrate === true;
866 - return new ReactSyncRoot(container, BatchedRoot, hydrate);
867 -}
868 -
869 -function warnIfReactDOMContainerInDEV(container) {
870 - if (__DEV__) {
871 - warningWithoutStack(
872 - !container._reactRootContainer,
873 - 'You are calling ReactDOM.%s() on a container that was previously ' +
874 - 'passed to ReactDOM.render(). This is not supported.',
875 - enableStableConcurrentModeAPIs ? 'createRoot' : 'unstable_createRoot',
876 - );
877 - container._reactHasBeenPassedToCreateRootDEV = true;
878 - }
879 -}
880 -
881 -if (enableStableConcurrentModeAPIs) {
882 - ReactDOM.createRoot = createRoot;
883 - ReactDOM.createSyncRoot = createSyncRoot;
884 -}
885 -
886 -const foundDevTools = injectIntoDevTools({
887 - findFiberByHostInstance: getClosestInstanceFromNode,
888 - bundleType: __DEV__ ? 1 : 0,
889 - version: ReactVersion,
890 - rendererPackageName: 'react-dom',
891 -});
892 -
893 -if (__DEV__) {
894 - if (!foundDevTools && canUseDOM && window.top === window.self) {
895 - // If we're in Chrome or Firefox, provide a download link if not installed.
896 - if (
897 - (navigator.userAgent.indexOf('Chrome') > -1 &&
898 - navigator.userAgent.indexOf('Edge') === -1) ||
899 - navigator.userAgent.indexOf('Firefox') > -1
900 - ) {
901 - const protocol = window.location.protocol;
902 - // Don't warn in exotic cases like chrome-extension://.
903 - if (/^(https?|file):$/.test(protocol)) {
904 - console.info(
905 - '%cDownload the React DevTools ' +
906 - 'for a better development experience: ' +
907 - 'https://fb.me/react-devtools' +
908 - (protocol === 'file:'
909 - ? '\nYou might need to use a local HTTP server (instead of file://): ' +
910 - 'https://fb.me/react-devtools-faq'
911 - : ''),
912 - 'font-weight:bold',
913 - );
914 - }
915 - }
916 - }
917 -}
918 -
919 -export default ReactDOM;
packages/react-dom/src/fire/ReactFireHostConfig.js deleted
-14
@@ -1,14 +0,0 @@
1 -/**
2 - * Copyright (c) Facebook, Inc. and its affiliates.
3 - *
4 - * This source code is licensed under the MIT license found in the
5 - * LICENSE file in the root directory of this source tree.
6 - *
7 - * @flow
8 - */
9 -
10 -// This is just to get the setup running.
11 -// TODO: real implementation.
12 -// console.log('Hello from Fire host config.');
13 -
14 -export * from '../client/ReactDOMHostConfig';
packages/react-dom/unstable-fire.js deleted
-16
@@ -1,16 +0,0 @@
1 -/**
2 - * Copyright (c) Facebook, Inc. and its affiliates.
3 - *
4 - * This source code is licensed under the MIT license found in the
5 - * LICENSE file in the root directory of this source tree.
6 - *
7 - * @flow
8 - */
9 -
10 -'use strict';
11 -
12 -const ReactFire = require('./src/fire/ReactFire');
13 -
14 -// TODO: decide on the top-level export form.
15 -// This is hacky but makes it work with both Rollup and Jest.
16 -module.exports = ReactFire.default || ReactFire;
packages/react-reconciler/src/forks/ReactFiberHostConfig.fire.js deleted
-10
@@ -1,10 +0,0 @@
1 -/**
2 - * Copyright (c) Facebook, Inc. and its affiliates.
3 - *
4 - * This source code is licensed under the MIT license found in the
5 - * LICENSE file in the root directory of this source tree.
6 - *
7 - * @flow
8 - */
9 -
10 -export * from 'react-dom/src/fire/ReactFireHostConfig';
scripts/jest/config.build.js
+1 -1
@@ -23,7 +23,7 @@ const packages = readdirSync(packagesRoot).filter(dir => {
23 const moduleNameMapper = {};
24
25 // Allow bundle tests to read (but not write!) default feature flags.
26 -// This lets us determine whether we're running in Fire mode
26 +// This lets us determine whether we're running in different modes
27 // without making relevant tests internal-only.
28 moduleNameMapper[
29 '^shared/ReactFeatureFlags'
scripts/jest/config.source-fire.js deleted
-12
@@ -1,12 +0,0 @@
1 -'use strict';
2 -
3 -const baseConfig = require('./config.base');
4 -
5 -module.exports = Object.assign({}, baseConfig, {
6 - roots: ['<rootDir>/packages/react-dom'],
7 - setupFiles: [
8 - ...baseConfig.setupFiles,
9 - require.resolve('./setupFire.js'),
10 - require.resolve('./setupHostConfigs.js'),
11 - ],
12 -});
scripts/jest/setupFire.js deleted
-9
@@ -1,9 +0,0 @@
1 -'use strict';
2 -
3 -jest.mock('react-dom', () => require.requireActual('react-dom/unstable-fire'));
4 -
5 -jest.mock('shared/ReactFeatureFlags', () => {
6 - const ReactFeatureFlags = require.requireActual('shared/ReactFeatureFlags');
7 - ReactFeatureFlags.disableInputAttributeSyncing = true;
8 - return ReactFeatureFlags;
9 -});
scripts/rollup/bundles.js
-19
@@ -95,25 +95,6 @@ const bundles = [
95 externals: ['react'],
96 },
97
98 - /******* React Fire *******/
99 - {
100 - bundleTypes: [
101 - UMD_DEV,
102 - UMD_PROD,
103 - UMD_PROFILING,
104 - NODE_DEV,
105 - NODE_PROD,
106 - NODE_PROFILING,
107 - FB_WWW_DEV,
108 - FB_WWW_PROD,
109 - FB_WWW_PROFILING,
110 - ],
111 - moduleType: RENDERER,
112 - entry: 'react-dom/unstable-fire',
113 - global: 'ReactFire',
114 - externals: ['react'],
115 - },
116 -
98 /******* Test Utils *******/
99 {
100 moduleType: RENDERER_UTILS,
scripts/shared/inlinedHostConfigs.js
-5
@@ -19,11 +19,6 @@ module.exports = [
19 isFlowTyped: true,
20 isFizzSupported: true,
21 },
22 - {
23 - shortName: 'fire',
24 - entryPoints: ['react-dom/unstable-fire'],
25 - isFlowTyped: true,
26 - },
22 {
23 shortName: 'art',
24 entryPoints: ['react-art'],