@samitouri / QOS-React / commits / 9097f3cdf0

Delete React Call/Return experiment (#12820)

Dan Abramov committed May 15, 2018 at 19:16 UTC 9097f3cdf089a34d873f3d349e3bfbed90852fad
20 files changed +3 -824
packages/react-call-return/README.md deleted
-32
@@ -1,32 +0,0 @@
1 -# react-call-return
2 -
3 -This is an experimental package for multi-pass rendering in React.
4 -
5 -**Its API is not as stable as that of React, React Native, or React DOM, and does not follow the common versioning scheme.**
6 -
7 -**Use it at your own risk.**
8 -
9 -# No, Really, It Is Unstable
10 -
11 -This is **an experiment**.
12 -
13 -We **will** replace this with a different API in the future.
14 -It can break between patch versions of React.
15 -
16 -We also know that **it has bugs**.
17 -
18 -Don't rely on this for anything except experiments.
19 -Even in experiments, make sure to lock the versions so that an update doesn't break your app.
20 -
21 -Don't publish third party components relying on this unless you clearly mark them as experimental too.
22 -They will break.
23 -
24 -Have fun! Let us know if you find interesting use cases for it.
25 -
26 -# API
27 -
28 -See the test case in `src/__tests__/ReactCallReturn.js` for an example.
29 -
30 -# What and Why
31 -
32 -The API is not very intuitive right now, but [this is a good overview](https://cdb.reacttraining.com/react-call-return-what-and-why-7e7761f81843) of why it might be useful in some cases. We are very open to better API ideas for this concept.
packages/react-call-return/index.js deleted
-12
@@ -1,12 +0,0 @@
1 -/**
2 - * Copyright (c) 2013-present, Facebook, Inc.
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 -module.exports = require('./src/ReactCallReturn');
packages/react-call-return/npm/index.js deleted
-7
@@ -1,7 +0,0 @@
1 -'use strict';
2 -
3 -if (process.env.NODE_ENV === 'production') {
4 - module.exports = require('./cjs/react-call-return.production.min.js');
5 -} else {
6 - module.exports = require('./cjs/react-call-return.development.js');
7 -}
packages/react-call-return/package.json deleted
-19
@@ -1,19 +0,0 @@
1 -{
2 - "name": "react-call-return",
3 - "description": "Experimental APIs for multi-pass rendering in React.",
4 - "version": "0.8.0",
5 - "repository": "facebook/react",
6 - "files": [
7 - "LICENSE",
8 - "README.md",
9 - "index.js",
10 - "cjs/"
11 - ],
12 - "dependencies": {
13 - "fbjs": "^0.8.16",
14 - "object-assign": "^4.1.1"
15 - },
16 - "peerDependencies": {
17 - "react": "^16.0.0"
18 - }
19 -}
packages/react-call-return/src/ReactCallReturn.js deleted
-95
@@ -1,95 +0,0 @@
1 -/**
2 - * Copyright (c) 2014-present, Facebook, Inc.
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 -import {
11 - REACT_CALL_TYPE,
12 - REACT_RETURN_TYPE,
13 - REACT_ELEMENT_TYPE,
14 -} from 'shared/ReactSymbols';
15 -
16 -import type {ReactCall, ReactNodeList, ReactReturn} from 'shared/ReactTypes';
17 -
18 -type CallHandler<T, V> = (props: T, returns: Array<V>) => ReactNodeList;
19 -
20 -export function unstable_createCall<T, V>(
21 - children: ReactNodeList,
22 - handler: CallHandler<T, V>,
23 - props: T,
24 - key: ?string = null,
25 -): ReactCall<V> {
26 - const call = {
27 - // This tag allow us to uniquely identify this as a React Call
28 - $$typeof: REACT_ELEMENT_TYPE,
29 - type: REACT_CALL_TYPE,
30 - key: key == null ? null : '' + key,
31 - ref: null,
32 - props: {
33 - props,
34 - handler,
35 - children: children,
36 - },
37 - };
38 -
39 - if (__DEV__) {
40 - // TODO: Add _store property for marking this as validated.
41 - if (Object.freeze) {
42 - Object.freeze(call.props);
43 - Object.freeze(call);
44 - }
45 - }
46 -
47 - return call;
48 -}
49 -
50 -export function unstable_createReturn<V>(value: V): ReactReturn<V> {
51 - const returnNode = {
52 - // This tag allow us to uniquely identify this as a React Call
53 - $$typeof: REACT_ELEMENT_TYPE,
54 - type: REACT_RETURN_TYPE,
55 - key: null,
56 - ref: null,
57 - props: {
58 - value,
59 - },
60 - };
61 -
62 - if (__DEV__) {
63 - // TODO: Add _store property for marking this as validated.
64 - if (Object.freeze) {
65 - Object.freeze(returnNode);
66 - }
67 - }
68 -
69 - return returnNode;
70 -}
71 -
72 -/**
73 - * Verifies the object is a call object.
74 - */
75 -export function unstable_isCall(object: mixed): boolean {
76 - return (
77 - typeof object === 'object' &&
78 - object !== null &&
79 - object.type === REACT_CALL_TYPE
80 - );
81 -}
82 -
83 -/**
84 - * Verifies the object is a return object.
85 - */
86 -export function unstable_isReturn(object: mixed): boolean {
87 - return (
88 - typeof object === 'object' &&
89 - object !== null &&
90 - object.type === REACT_RETURN_TYPE
91 - );
92 -}
93 -
94 -export const unstable_REACT_RETURN_TYPE = REACT_RETURN_TYPE;
95 -export const unstable_REACT_CALL_TYPE = REACT_CALL_TYPE;
packages/react-call-return/src/__tests__/ReactCallReturn-test.internal.js deleted
-326
@@ -1,326 +0,0 @@
1 -/**
2 - * Copyright (c) 2013-present, Facebook, Inc.
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 - * @emails react-core
8 - */
9 -
10 -'use strict';
11 -
12 -let React;
13 -let ReactFeatureFlags;
14 -let ReactNoop;
15 -let ReactCallReturn;
16 -
17 -describe('ReactCallReturn', () => {
18 - beforeEach(() => {
19 - jest.resetModules();
20 - ReactFeatureFlags = require('shared/ReactFeatureFlags');
21 - ReactFeatureFlags.debugRenderPhaseSideEffectsForStrictMode = false;
22 - React = require('react');
23 - ReactNoop = require('react-noop-renderer');
24 - ReactCallReturn = require('react-call-return');
25 - });
26 -
27 - function div(...children) {
28 - children = children.map(c => (typeof c === 'string' ? {text: c} : c));
29 - return {type: 'div', children, prop: undefined};
30 - }
31 -
32 - function span(prop) {
33 - return {type: 'span', children: [], prop};
34 - }
35 -
36 - it('should render a call', () => {
37 - const ops = [];
38 -
39 - function Continuation({isSame}) {
40 - ops.push(['Continuation', isSame]);
41 - return <span prop={isSame ? 'foo==bar' : 'foo!=bar'} />;
42 - }
43 -
44 - // An alternative API could mark Continuation as something that needs
45 - // returning. E.g. Continuation.returnType = 123;
46 - function Child({bar}) {
47 - ops.push(['Child', bar]);
48 - return ReactCallReturn.unstable_createReturn({
49 - props: {
50 - bar: bar,
51 - },
52 - continuation: Continuation,
53 - });
54 - }
55 -
56 - function Indirection() {
57 - ops.push('Indirection');
58 - return [<Child key="a" bar={true} />, <Child key="b" bar={false} />];
59 - }
60 -
61 - function HandleReturns(props, returns) {
62 - ops.push('HandleReturns');
63 - return returns.map((y, i) => (
64 - <y.continuation key={i} isSame={props.foo === y.props.bar} />
65 - ));
66 - }
67 -
68 - // An alternative API could mark Parent as something that needs
69 - // returning. E.g. Parent.handler = HandleReturns;
70 - function Parent(props) {
71 - ops.push('Parent');
72 - return ReactCallReturn.unstable_createCall(
73 - props.children,
74 - HandleReturns,
75 - props,
76 - );
77 - }
78 -
79 - function App() {
80 - return (
81 - <div>
82 - <Parent foo={true}>
83 - <Indirection />
84 - </Parent>
85 - </div>
86 - );
87 - }
88 -
89 - ReactNoop.render(<App />);
90 - ReactNoop.flush();
91 -
92 - expect(ops).toEqual([
93 - 'Parent',
94 - 'Indirection',
95 - ['Child', true],
96 - // Return
97 - ['Child', false],
98 - // Return
99 - 'HandleReturns',
100 - // Call continuations
101 - ['Continuation', true],
102 - ['Continuation', false],
103 - ]);
104 - expect(ReactNoop.getChildren()).toEqual([
105 - div(span('foo==bar'), span('foo!=bar')),
106 - ]);
107 - });
108 -
109 - it('should update a call', () => {
110 - function Continuation({isSame}) {
111 - return <span prop={isSame ? 'foo==bar' : 'foo!=bar'} />;
112 - }
113 -
114 - function Child({bar}) {
115 - return ReactCallReturn.unstable_createReturn({
116 - props: {
117 - bar: bar,
118 - },
119 - continuation: Continuation,
120 - });
121 - }
122 -
123 - function Indirection() {
124 - return [<Child key="a" bar={true} />, <Child key="b" bar={false} />];
125 - }
126 -
127 - function HandleReturns(props, returns) {
128 - return returns.map((y, i) => (
129 - <y.continuation key={i} isSame={props.foo === y.props.bar} />
130 - ));
131 - }
132 -
133 - function Parent(props) {
134 - return ReactCallReturn.unstable_createCall(
135 - props.children,
136 - HandleReturns,
137 - props,
138 - );
139 - }
140 -
141 - function App(props) {
142 - return (
143 - <div>
144 - <Parent foo={props.foo}>
145 - <Indirection />
146 - </Parent>
147 - </div>
148 - );
149 - }
150 -
151 - ReactNoop.render(<App foo={true} />);
152 - ReactNoop.flush();
153 - expect(ReactNoop.getChildren()).toEqual([
154 - div(span('foo==bar'), span('foo!=bar')),
155 - ]);
156 -
157 - ReactNoop.render(<App foo={false} />);
158 - ReactNoop.flush();
159 - expect(ReactNoop.getChildren()).toEqual([
160 - div(span('foo!=bar'), span('foo==bar')),
161 - ]);
162 - });
163 -
164 - it('should unmount a composite in a call', () => {
165 - let ops = [];
166 -
167 - class Continuation extends React.Component {
168 - render() {
169 - ops.push('Continuation');
170 - return <div />;
171 - }
172 - componentWillUnmount() {
173 - ops.push('Unmount Continuation');
174 - }
175 - }
176 -
177 - class Child extends React.Component {
178 - render() {
179 - ops.push('Child');
180 - return ReactCallReturn.unstable_createReturn(Continuation);
181 - }
182 - componentWillUnmount() {
183 - ops.push('Unmount Child');
184 - }
185 - }
186 -
187 - function HandleReturns(props, returns) {
188 - ops.push('HandleReturns');
189 - return returns.map((ContinuationComponent, i) => (
190 - <ContinuationComponent key={i} />
191 - ));
192 - }
193 -
194 - class Parent extends React.Component {
195 - render() {
196 - ops.push('Parent');
197 - return ReactCallReturn.unstable_createCall(
198 - this.props.children,
199 - HandleReturns,
200 - this.props,
201 - );
202 - }
203 - componentWillUnmount() {
204 - ops.push('Unmount Parent');
205 - }
206 - }
207 -
208 - ReactNoop.render(
209 - <Parent>
210 - <Child />
211 - </Parent>,
212 - );
213 - ReactNoop.flush();
214 -
215 - expect(ops).toEqual(['Parent', 'Child', 'HandleReturns', 'Continuation']);
216 -
217 - ops = [];
218 -
219 - ReactNoop.render(<div />);
220 - ReactNoop.flush();
221 -
222 - expect(ops).toEqual([
223 - 'Unmount Parent',
224 - 'Unmount Child',
225 - 'Unmount Continuation',
226 - ]);
227 - });
228 -
229 - it('should handle deep updates in call', () => {
230 - let instances = {};
231 -
232 - class Counter extends React.Component {
233 - state = {value: 5};
234 - render() {
235 - instances[this.props.id] = this;
236 - return ReactCallReturn.unstable_createReturn(this.state.value);
237 - }
238 - }
239 -
240 - function App(props) {
241 - return ReactCallReturn.unstable_createCall(
242 - [
243 - <Counter key="a" id="a" />,
244 - <Counter key="b" id="b" />,
245 - <Counter key="c" id="c" />,
246 - ],
247 - (p, returns) => returns.map((y, i) => <span key={i} prop={y * 100} />),
248 - {},
249 - );
250 - }
251 -
252 - ReactNoop.render(<App />);
253 - ReactNoop.flush();
254 - expect(ReactNoop.getChildren()).toEqual([span(500), span(500), span(500)]);
255 -
256 - instances.a.setState({value: 1});
257 - instances.b.setState({value: 2});
258 - ReactNoop.flush();
259 - expect(ReactNoop.getChildren()).toEqual([span(100), span(200), span(500)]);
260 - });
261 -
262 - it('should unmount and remount children', () => {
263 - let ops = [];
264 -
265 - class Call extends React.Component {
266 - render() {
267 - return ReactCallReturn.unstable_createCall(
268 - this.props.children,
269 - (p, returns) => returns,
270 - {},
271 - );
272 - }
273 - }
274 -
275 - class Return extends React.Component {
276 - render() {
277 - ops.push(`Return ${this.props.value}`);
278 - return ReactCallReturn.unstable_createReturn(this.props.children);
279 - }
280 -
281 - UNSAFE_componentWillMount() {
282 - ops.push(`Mount Return ${this.props.value}`);
283 - }
284 -
285 - componentWillUnmount() {
286 - ops.push(`Unmount Return ${this.props.value}`);
287 - }
288 - }
289 -
290 - ReactNoop.render(
291 - <Call>
292 - <Return value={1} />
293 - <Return value={2} />
294 - </Call>,
295 - );
296 - expect(ReactNoop.flush).toWarnDev(
297 - 'componentWillMount: Please update the following components ' +
298 - 'to use componentDidMount instead: Return',
299 - );
300 -
301 - expect(ops).toEqual([
302 - 'Mount Return 1',
303 - 'Return 1',
304 - 'Mount Return 2',
305 - 'Return 2',
306 - ]);
307 -
308 - ops = [];
309 -
310 - ReactNoop.render(<Call />);
311 - ReactNoop.flush();
312 -
313 - expect(ops).toEqual(['Unmount Return 1', 'Unmount Return 2']);
314 -
315 - ops = [];
316 -
317 - ReactNoop.render(
318 - <Call>
319 - <Return value={3} />
320 - </Call>,
321 - );
322 - ReactNoop.flush();
323 -
324 - expect(ops).toEqual(['Mount Return 3', 'Return 3']);
325 - });
326 -});
packages/react-dom/src/__tests__/ReactServerRendering-test.internal.js
-21
@@ -11,7 +11,6 @@
11 'use strict';
12
13 let React;
14 -let ReactCallReturn;
14 let ReactDOMServer;
15 let PropTypes;
16
@@ -23,7 +22,6 @@ describe('ReactDOMServer', () => {
22 beforeEach(() => {
23 jest.resetModules();
24 React = require('react');
26 - ReactCallReturn = require('react-call-return');
25 PropTypes = require('prop-types');
26 ReactDOMServer = require('react-dom/server');
27 });
@@ -623,25 +621,6 @@ describe('ReactDOMServer', () => {
621 );
622 });
623
626 - it('should throw rendering call/return on the server', () => {
627 - expect(() => {
628 - ReactDOMServer.renderToString(
629 - <div>{ReactCallReturn.unstable_createReturn(42)}</div>,
630 - );
631 - }).toThrow(
632 - 'The experimental Call and Return types are not currently supported by the server renderer.',
633 - );
634 - expect(() => {
635 - ReactDOMServer.renderToString(
636 - <div>
637 - {ReactCallReturn.unstable_createCall(null, function() {}, {})}
638 - </div>,
639 - );
640 - }).toThrow(
641 - 'The experimental Call and Return types are not currently supported by the server renderer.',
642 - );
643 - });
644 -
624 it('should warn when server rendering a class with a render method that does not extend React.Component', () => {
625 class ClassWithRenderNotExtended {
626 render() {
packages/react-dom/src/server/ReactPartialRenderer.js
-9
@@ -31,8 +31,6 @@ import {
31 REACT_FRAGMENT_TYPE,
32 REACT_STRICT_MODE_TYPE,
33 REACT_ASYNC_MODE_TYPE,
34 - REACT_CALL_TYPE,
35 - REACT_RETURN_TYPE,
34 REACT_PORTAL_TYPE,
35 REACT_PROFILER_TYPE,
36 REACT_PROVIDER_TYPE,
@@ -831,13 +829,6 @@ class ReactDOMServerRenderer {
829 this.stack.push(frame);
830 return '';
831 }
834 - case REACT_CALL_TYPE:
835 - case REACT_RETURN_TYPE:
836 - invariant(
837 - false,
838 - 'The experimental Call and Return types are not currently ' +
839 - 'supported by the server renderer.',
840 - );
832 // eslint-disable-next-line-no-fallthrough
833 default:
834 break;
packages/react-reconciler/src/ReactDebugFiberPerf.js
-4
@@ -16,8 +16,6 @@ import {
16 HostComponent,
17 HostText,
18 HostPortal,
19 - CallComponent,
20 - ReturnComponent,
19 Fragment,
20 ContextProvider,
21 ContextConsumer,
@@ -171,8 +169,6 @@ const shouldIgnoreFiber = (fiber: Fiber): boolean => {
169 case HostComponent:
170 case HostText:
171 case HostPortal:
174 - case CallComponent:
175 - case ReturnComponent:
172 case Fragment:
173 case ContextProvider:
174 case ContextConsumer:
packages/react-reconciler/src/ReactFiber.js
-10
@@ -24,8 +24,6 @@ import {
24 HostComponent,
25 HostText,
26 HostPortal,
27 - CallComponent,
28 - ReturnComponent,
27 ForwardRef,
28 Fragment,
29 Mode,
@@ -41,8 +39,6 @@ import {NoContext, AsyncMode, ProfileMode, StrictMode} from './ReactTypeOfMode';
39 import {
40 REACT_FORWARD_REF_TYPE,
41 REACT_FRAGMENT_TYPE,
44 - REACT_RETURN_TYPE,
45 - REACT_CALL_TYPE,
42 REACT_STRICT_MODE_TYPE,
43 REACT_PROFILER_TYPE,
44 REACT_PROVIDER_TYPE,
@@ -364,12 +360,6 @@ export function createFiberFromElement(
360 break;
361 case REACT_PROFILER_TYPE:
362 return createFiberFromProfiler(pendingProps, mode, expirationTime, key);
367 - case REACT_CALL_TYPE:
368 - fiberTag = CallComponent;
369 - break;
370 - case REACT_RETURN_TYPE:
371 - fiberTag = ReturnComponent;
372 - break;
363 case REACT_TIMEOUT_TYPE:
364 fiberTag = TimeoutComponent;
365 // Suspense does not require async, but its children should be strict
packages/react-reconciler/src/ReactFiberBeginWork.js
-55
@@ -27,9 +27,6 @@ import {
27 HostComponent,
28 HostText,
29 HostPortal,
30 - CallComponent,
31 - CallHandlerPhase,
32 - ReturnComponent,
30 ForwardRef,
31 Fragment,
32 Mode,
@@ -741,44 +738,6 @@ export default function<T, P, I, TI, HI, PI, C, CC, CX, PL>(
738 }
739 }
740
744 - function updateCallComponent(current, workInProgress, renderExpirationTime) {
745 - let nextProps = workInProgress.pendingProps;
746 - if (hasLegacyContextChanged()) {
747 - // Normally we can bail out on props equality but if context has changed
748 - // we don't do the bailout and we have to reuse existing props instead.
749 - } else if (workInProgress.memoizedProps === nextProps) {
750 - nextProps = workInProgress.memoizedProps;
751 - // TODO: When bailing out, we might need to return the stateNode instead
752 - // of the child. To check it for work.
753 - // return bailoutOnAlreadyFinishedWork(current, workInProgress);
754 - }
755 -
756 - const nextChildren = nextProps.children;
757 -
758 - // The following is a fork of reconcileChildrenAtExpirationTime but using
759 - // stateNode to store the child.
760 - if (current === null) {
761 - workInProgress.stateNode = mountChildFibers(
762 - workInProgress,
763 - workInProgress.stateNode,
764 - nextChildren,
765 - renderExpirationTime,
766 - );
767 - } else {
768 - workInProgress.stateNode = reconcileChildFibers(
769 - workInProgress,
770 - current.stateNode,
771 - nextChildren,
772 - renderExpirationTime,
773 - );
774 - }
775 -
776 - memoizeProps(workInProgress, nextProps);
777 - // This doesn't take arbitrary time so we could synchronously just begin
778 - // eagerly do the work of workInProgress.child as an optimization.
779 - return workInProgress.stateNode;
780 - }
781 -
741 function updateTimeoutComponent(
742 current,
743 workInProgress,
@@ -1260,20 +1219,6 @@ export default function<T, P, I, TI, HI, PI, C, CC, CX, PL>(
1219 );
1220 case HostText:
1221 return updateHostText(current, workInProgress);
1263 - case CallHandlerPhase:
1264 - // This is a restart. Reset the tag to the initial phase.
1265 - workInProgress.tag = CallComponent;
1266 - // Intentionally fall through since this is now the same.
1267 - case CallComponent:
1268 - return updateCallComponent(
1269 - current,
1270 - workInProgress,
1271 - renderExpirationTime,
1272 - );
1273 - case ReturnComponent:
1274 - // A return component is just a placeholder, we can just run through the
1275 - // next one immediately.
1276 - return null;
1222 case TimeoutComponent:
1223 return updateTimeoutComponent(
1224 current,
packages/react-reconciler/src/ReactFiberCommitWork.js
-5
@@ -25,7 +25,6 @@ import {
25 HostComponent,
26 HostText,
27 HostPortal,
28 - CallComponent,
28 Profiler,
29 TimeoutComponent,
30 } from 'shared/ReactTypeOfWork';
@@ -393,10 +392,6 @@ export default function<T, P, I, TI, HI, PI, C, CC, CX, PL>(
392 safelyDetachRef(current);
393 return;
394 }
396 - case CallComponent: {
397 - commitNestedUnmounts(current.stateNode);
398 - return;
399 - }
395 case HostPortal: {
396 // TODO: this is recursive.
397 // We are also not using this parent because
packages/react-reconciler/src/ReactFiberCompleteWork.js
-87
@@ -31,9 +31,6 @@ import {
31 HostComponent,
32 HostText,
33 HostPortal,
34 - CallComponent,
35 - CallHandlerPhase,
36 - ReturnComponent,
34 ContextProvider,
35 ContextConsumer,
36 ForwardRef,
@@ -45,8 +42,6 @@ import {
42 import {Placement, Ref, Update} from 'shared/ReactTypeOfSideEffect';
43 import invariant from 'fbjs/lib/invariant';
44
48 -import {reconcileChildFibers} from './ReactChildFiber';
49 -
45 export default function<T, P, I, TI, HI, PI, C, CC, CX, PL>(
46 config: HostConfig<T, P, I, TI, HI, PI, C, CC, CX, PL>,
47 hostContext: HostContext<C, CX>,
@@ -97,75 +92,6 @@ export default function<T, P, I, TI, HI, PI, C, CC, CX, PL>(
92 workInProgress.effectTag |= Ref;
93 }
94
100 - function appendAllReturns(returns: Array<mixed>, workInProgress: Fiber) {
101 - let node = workInProgress.stateNode;
102 - if (node) {
103 - node.return = workInProgress;
104 - }
105 - while (node !== null) {
106 - if (
107 - node.tag === HostComponent ||
108 - node.tag === HostText ||
109 - node.tag === HostPortal
110 - ) {
111 - invariant(false, 'A call cannot have host component children.');
112 - } else if (node.tag === ReturnComponent) {
113 - returns.push(node.pendingProps.value);
114 - } else if (node.child !== null) {
115 - node.child.return = node;
116 - node = node.child;
117 - continue;
118 - }
119 - while (node.sibling === null) {
120 - if (node.return === null || node.return === workInProgress) {
121 - return;
122 - }
123 - node = node.return;
124 - }
125 - node.sibling.return = node.return;
126 - node = node.sibling;
127 - }
128 - }
129 -
130 - function moveCallToHandlerPhase(
131 - current: Fiber | null,
132 - workInProgress: Fiber,
133 - renderExpirationTime: ExpirationTime,
134 - ) {
135 - const props = workInProgress.memoizedProps;
136 - invariant(
137 - props,
138 - 'Should be resolved by now. This error is likely caused by a bug in ' +
139 - 'React. Please file an issue.',
140 - );
141 -
142 - // First step of the call has completed. Now we need to do the second.
143 - // TODO: It would be nice to have a multi stage call represented by a
144 - // single component, or at least tail call optimize nested ones. Currently
145 - // that requires additional fields that we don't want to add to the fiber.
146 - // So this requires nested handlers.
147 - // Note: This doesn't mutate the alternate node. I don't think it needs to
148 - // since this stage is reset for every pass.
149 - workInProgress.tag = CallHandlerPhase;
150 -
151 - // Build up the returns.
152 - // TODO: Compare this to a generator or opaque helpers like Children.
153 - const returns: Array<mixed> = [];
154 - appendAllReturns(returns, workInProgress);
155 - const fn = props.handler;
156 - const childProps = props.props;
157 - const nextChildren = fn(childProps, returns);
158 -
159 - const currentFirstChild = current !== null ? current.child : null;
160 - workInProgress.child = reconcileChildFibers(
161 - workInProgress,
162 - currentFirstChild,
163 - nextChildren,
164 - renderExpirationTime,
165 - );
166 - return workInProgress.child;
167 - }
168 -
95 function appendAllChildren(parent: I, workInProgress: Fiber) {
96 // We only have the top Fiber that was created but we need recurse down its
97 // children to find all the terminal nodes.
@@ -579,19 +505,6 @@ export default function<T, P, I, TI, HI, PI, C, CC, CX, PL>(
505 }
506 return null;
507 }
582 - case CallComponent:
583 - return moveCallToHandlerPhase(
584 - current,
585 - workInProgress,
586 - renderExpirationTime,
587 - );
588 - case CallHandlerPhase:
589 - // Reset the tag to now be a first phase call.
590 - workInProgress.tag = CallComponent;
591 - return null;
592 - case ReturnComponent:
593 - // Does nothing.
594 - return null;
508 case ForwardRef:
509 return null;
510 case TimeoutComponent:
packages/react-reconciler/src/__tests__/ReactIncrementalPerf-test.internal.js
-49
@@ -12,7 +12,6 @@
12
13 describe('ReactDebugFiberPerf', () => {
14 let React;
15 - let ReactCallReturn;
15 let ReactNoop;
16 let PropTypes;
17
@@ -121,7 +120,6 @@ describe('ReactDebugFiberPerf', () => {
120 // Import after the polyfill is set up:
121 React = require('react');
122 ReactNoop = require('react-noop-renderer');
124 - ReactCallReturn = require('react-call-return');
123 PropTypes = require('prop-types');
124 });
125
@@ -535,53 +533,6 @@ describe('ReactDebugFiberPerf', () => {
533 expect(getFlameChart()).toMatchSnapshot();
534 });
535
538 - it('supports returns', () => {
539 - function Continuation({isSame}) {
540 - return <span prop={isSame ? 'foo==bar' : 'foo!=bar'} />;
541 - }
542 -
543 - function CoChild({bar}) {
544 - return ReactCallReturn.unstable_createReturn({
545 - props: {
546 - bar: bar,
547 - },
548 - continuation: Continuation,
549 - });
550 - }
551 -
552 - function Indirection() {
553 - return [<CoChild key="a" bar={true} />, <CoChild key="b" bar={false} />];
554 - }
555 -
556 - function HandleReturns(props, returns) {
557 - return returns.map((y, i) => (
558 - <y.continuation key={i} isSame={props.foo === y.props.bar} />
559 - ));
560 - }
561 -
562 - function CoParent(props) {
563 - return ReactCallReturn.unstable_createCall(
564 - props.children,
565 - HandleReturns,
566 - props,
567 - );
568 - }
569 -
570 - function App() {
571 - return (
572 - <div>
573 - <CoParent foo={true}>
574 - <Indirection />
575 - </CoParent>
576 - </div>
577 - );
578 - }
579 -
580 - ReactNoop.render(<App />);
581 - ReactNoop.flush();
582 - expect(getFlameChart()).toMatchSnapshot();
583 - });
584 -
536 it('supports portals', () => {
537 const noopContainer = {children: []};
538 ReactNoop.render(
packages/react-reconciler/src/__tests__/__snapshots__/ReactIncrementalPerf-test.internal.js.snap
-19
@@ -370,25 +370,6 @@ exports[`ReactDebugFiberPerf supports portals 1`] = `
370 "
371 `;
372
373 -exports[`ReactDebugFiberPerf supports returns 1`] = `
374 -"⚛ (Waiting for async callback... will force flush in 5250 ms)
375 -
376 -⚛ (React Tree Reconciliation: Completed Root)
377 - ⚛ App [mount]
378 - ⚛ CoParent [mount]
379 - ⚛ Indirection [mount]
380 - ⚛ CoChild [mount]
381 - ⚛ CoChild [mount]
382 - ⚛ Continuation [mount]
383 - ⚛ Continuation [mount]
384 -
385 -⚛ (Committing Changes)
386 - ⚛ (Committing Snapshot Effects: 0 Total)
387 - ⚛ (Committing Host Effects: 3 Total)
388 - ⚛ (Calling Lifecycle Methods: 0 Total)
389 -"
390 -`;
391 -
373 exports[`ReactDebugFiberPerf warns if an in-progress update is interrupted 1`] = `
374 "⚛ (Waiting for async callback... will force flush in 5250 ms)
375
packages/react/src/__tests__/ReactChildren-test.js
-51
@@ -69,57 +69,6 @@ describe('ReactChildren', () => {
69 expect(mappedChildren[0]).toEqual(reactPortal);
70 });
71
72 - it('should support Call components', () => {
73 - const context = {};
74 - const callback = jasmine.createSpy().and.callFake(function(kid, index) {
75 - expect(this).toBe(context);
76 - return kid;
77 - });
78 - const ReactCallReturn = require('react-call-return');
79 - const reactCall = ReactCallReturn.unstable_createCall(
80 - <span key="simple" />,
81 - () => {},
82 - );
83 -
84 - const parentInstance = <div>{reactCall}</div>;
85 - React.Children.forEach(parentInstance.props.children, callback, context);
86 - expect(callback).toHaveBeenCalledWith(reactCall, 0);
87 - callback.calls.reset();
88 - const mappedChildren = React.Children.map(
89 - parentInstance.props.children,
90 - callback,
91 - context,
92 - );
93 - expect(callback).toHaveBeenCalledWith(reactCall, 0);
94 - expect(mappedChildren[0].type).toEqual(reactCall.type);
95 - expect(mappedChildren[0].props).toEqual(reactCall.props);
96 - });
97 -
98 - it('should support Return components', () => {
99 - const context = {};
100 - const callback = jasmine.createSpy().and.callFake(function(kid, index) {
101 - expect(this).toBe(context);
102 - return kid;
103 - });
104 - const ReactCallReturn = require('react-call-return');
105 - const reactReturn = ReactCallReturn.unstable_createReturn(
106 - <span key="simple" />,
107 - );
108 -
109 - const parentInstance = <div>{reactReturn}</div>;
110 - React.Children.forEach(parentInstance.props.children, callback, context);
111 - expect(callback).toHaveBeenCalledWith(reactReturn, 0);
112 - callback.calls.reset();
113 - const mappedChildren = React.Children.map(
114 - parentInstance.props.children,
115 - callback,
116 - context,
117 - );
118 - expect(callback).toHaveBeenCalledWith(reactReturn, 0);
119 - expect(mappedChildren[0].props).toEqual(reactReturn.props);
120 - expect(mappedChildren[0].type).toEqual(reactReturn.type);
121 - });
122 -
72 it('should treat single arrayless child as being in array', () => {
73 const context = {};
74 const callback = jasmine.createSpy().and.callFake(function(kid, index) {
packages/shared/ReactSymbols.js
-4
@@ -14,10 +14,6 @@ const hasSymbol = typeof Symbol === 'function' && Symbol.for;
14 export const REACT_ELEMENT_TYPE = hasSymbol
15 ? Symbol.for('react.element')
16 : 0xeac7;
17 -export const REACT_CALL_TYPE = hasSymbol ? Symbol.for('react.call') : 0xeac8;
18 -export const REACT_RETURN_TYPE = hasSymbol
19 - ? Symbol.for('react.return')
20 - : 0xeac9;
17 export const REACT_PORTAL_TYPE = hasSymbol
18 ? Symbol.for('react.portal')
19 : 0xeaca;
packages/shared/ReactTypeOfWork.js
+3 -3
@@ -33,9 +33,9 @@ export const HostRoot = 3; // Root of a host tree. Could be nested inside anothe
33 export const HostPortal = 4; // A subtree. Could be an entry point to a different renderer.
34 export const HostComponent = 5;
35 export const HostText = 6;
36 -export const CallComponent = 7;
37 -export const CallHandlerPhase = 8;
38 -export const ReturnComponent = 9;
36 +export const CallComponent_UNUSED = 7;
37 +export const CallHandlerPhase_UNUSED = 8;
38 +export const ReturnComponent_UNUSED = 9;
39 export const Fragment = 10;
40 export const Mode = 11;
41 export const ContextConsumer = 12;
packages/shared/getComponentName.js
-6
@@ -11,14 +11,12 @@ import type {Fiber} from 'react-reconciler/src/ReactFiber';
11
12 import {
13 REACT_ASYNC_MODE_TYPE,
14 - REACT_CALL_TYPE,
14 REACT_CONTEXT_TYPE,
15 REACT_FORWARD_REF_TYPE,
16 REACT_FRAGMENT_TYPE,
17 REACT_PORTAL_TYPE,
18 REACT_PROFILER_TYPE,
19 REACT_PROVIDER_TYPE,
21 - REACT_RETURN_TYPE,
20 REACT_STRICT_MODE_TYPE,
21 } from 'shared/ReactSymbols';
22
@@ -33,8 +31,6 @@ function getComponentName(fiber: Fiber): string | null {
31 switch (type) {
32 case REACT_ASYNC_MODE_TYPE:
33 return 'AsyncMode';
36 - case REACT_CALL_TYPE:
37 - return 'ReactCall';
34 case REACT_CONTEXT_TYPE:
35 return 'Context.Consumer';
36 case REACT_FRAGMENT_TYPE:
@@ -45,8 +41,6 @@ function getComponentName(fiber: Fiber): string | null {
41 return `Profiler(${fiber.pendingProps.id})`;
42 case REACT_PROVIDER_TYPE:
43 return 'Context.Provider';
48 - case REACT_RETURN_TYPE:
49 - return 'ReactReturn';
44 case REACT_STRICT_MODE_TYPE:
45 return 'StrictMode';
46 }
scripts/rollup/bundles.js
-10
@@ -328,16 +328,6 @@ const bundles = [
328 externals: [],
329 },
330
331 - /******* React Call Return (experimental) *******/
332 - {
333 - label: 'react-call-return',
334 - bundleTypes: [NODE_DEV, NODE_PROD],
335 - moduleType: ISOMORPHIC,
336 - entry: 'react-call-return',
337 - global: 'ReactCallReturn',
338 - externals: [],
339 - },
340 -
331 /******* React Is *******/
332 {
333 label: 'react-is',