From faed6ae23bd1f2cc57fa3506af92abcf6d318b1f Mon Sep 17 00:00:00 2001 From: sebmarkbage Date: Sun, 21 Apr 2024 16:56:25 +0000 Subject: [PATCH] Warn for Child Iterator of all types but allow Generator Components (#28853) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This doesn't change production behavior. We always render Iterables to our best effort in prod even if they're Iterators. But this does change the DEV warnings which indicates which are valid patterns to use. It's a footgun to use an Iterator as a prop when you pass between components because if an intermediate component rerenders without its parent, React won't be able to iterate it again to reconcile and any mappers won't be able to re-apply. This is actually typically not a problem when passed only to React host components but as a pattern it's a problem for composability. We used to warn only for Generators - i.e. Iterators returned from Generator functions. This adds a warning for Iterators created by other means too (e.g. Flight or the native Iterator utils). The heuristic is to check whether the Iterator is the same as the Iterable because that means it's not possible to get new iterators out of it. This case used to just yield non-sense like empty sets in DEV but not in prod. However, a new realization is that when the Component itself is a Generator Function, it's not actually a problem. That's because the React Element itself works as an Iterable since we can ask for new generators by calling the function again. So this adds a special case to allow the Generator returned from a Generator Function's direct child. The principle is “don’t pass iterators around” but in this case there is no iterator floating around because it’s between React and the JS VM. Also see #28849 for context on AsyncIterables. Related to this, but Hooks should ideally be banned in these for the same reason they're banned in Async Functions. DiffTrain build for commit https://github.com/facebook/react/commit/368202181e772d411b2445930aea1edd9428b09b. --- .../cjs/ReactTestRenderer-dev.js | 66 +++++++++---------- .../cjs/ReactTestRenderer-prod.js | 12 ++-- .../cjs/ReactTestRenderer-profiling.js | 12 ++-- .../vendor/react/cjs/JSXDEVRuntime-dev.js | 13 ++-- .../vendor/react/cjs/JSXRuntime-dev.js | 13 ++-- .../RKJSModules/vendor/react/cjs/React-dev.js | 15 +++-- .../Libraries/Renderer/REVISION | 2 +- .../implementations/ReactFabric-dev.fb.js | 66 +++++++++---------- .../implementations/ReactFabric-prod.fb.js | 12 ++-- .../ReactFabric-profiling.fb.js | 12 ++-- .../ReactNativeRenderer-dev.fb.js | 66 +++++++++---------- .../ReactNativeRenderer-prod.fb.js | 12 ++-- .../ReactNativeRenderer-profiling.fb.js | 12 ++-- 13 files changed, 155 insertions(+), 158 deletions(-) diff --git a/compiled-rn/facebook-fbsource/xplat/js/RKJSModules/vendor/react-test-renderer/cjs/ReactTestRenderer-dev.js b/compiled-rn/facebook-fbsource/xplat/js/RKJSModules/vendor/react-test-renderer/cjs/ReactTestRenderer-dev.js index 558318d79c773..c0ab6902ae7a0 100644 --- a/compiled-rn/facebook-fbsource/xplat/js/RKJSModules/vendor/react-test-renderer/cjs/ReactTestRenderer-dev.js +++ b/compiled-rn/facebook-fbsource/xplat/js/RKJSModules/vendor/react-test-renderer/cjs/ReactTestRenderer-dev.js @@ -7,7 +7,7 @@ * @noflow * @nolint * @preventMunge - * @generated SignedSource<<8514bdf3885188125eab2e51d9ecb536>> + * @generated SignedSource<> */ 'use strict'; @@ -6141,45 +6141,36 @@ function createChildReconciler(shouldTrackSideEffects) { throw new Error('An object is not an iterable. This error is likely caused by a bug in ' + 'React. Please file an issue.'); } - { - // We don't support rendering Generators because it's a mutation. - // See https://github.com/facebook/react/issues/12995 - if (typeof Symbol === 'function' && // $FlowFixMe[prop-missing] Flow doesn't know about toStringTag - newChildrenIterable[Symbol.toStringTag] === 'Generator') { - if (!didWarnAboutGenerators) { - error('Using Generators as children is unsupported and will likely yield ' + 'unexpected results because enumerating a generator mutates it. ' + 'You may convert it to an array with `Array.from()` or the ' + '`[...spread]` operator before rendering. Keep in mind ' + 'you might need to polyfill these features for older browsers.'); - } - - didWarnAboutGenerators = true; - } // Warn about using Maps as children + var newChildren = iteratorFn.call(newChildrenIterable); + { + if (newChildren === newChildrenIterable) { + // We don't support rendering Generators as props because it's a mutation. + // See https://github.com/facebook/react/issues/12995 + // We do support generators if they were created by a GeneratorFunction component + // as its direct child since we can recreate those by rerendering the component + // as needed. + var isGeneratorComponent = returnFiber.tag === FunctionComponent && // $FlowFixMe[method-unbinding] + Object.prototype.toString.call(returnFiber.type) === '[object GeneratorFunction]' && // $FlowFixMe[method-unbinding] + Object.prototype.toString.call(newChildren) === '[object Generator]'; + + if (!isGeneratorComponent) { + if (!didWarnAboutGenerators) { + error('Using Iterators as children is unsupported and will likely yield ' + 'unexpected results because enumerating a generator mutates it. ' + 'You may convert it to an array with `Array.from()` or the ' + '`[...spread]` operator before rendering. You can also use an ' + 'Iterable that can iterate multiple times over the same items.'); + } - if (newChildrenIterable.entries === iteratorFn) { + didWarnAboutGenerators = true; + } + } else if (newChildrenIterable.entries === iteratorFn) { + // Warn about using Maps as children if (!didWarnAboutMaps) { error('Using Maps as children is not supported. ' + 'Use an array of keyed ReactElements instead.'); - } - - didWarnAboutMaps = true; - } // First, validate keys. - // We'll get a different iterator later for the main pass. - - var _newChildren = iteratorFn.call(newChildrenIterable); - - if (_newChildren) { - var knownKeys = null; - - var _step = _newChildren.next(); - - for (; !_step.done; _step = _newChildren.next()) { - var child = _step.value; - knownKeys = warnOnInvalidKey(child, knownKeys, returnFiber); + didWarnAboutMaps = true; } } } - var newChildren = iteratorFn.call(newChildrenIterable); - if (newChildren == null) { throw new Error('An iterable object provided no iterator.'); } @@ -6190,9 +6181,14 @@ function createChildReconciler(shouldTrackSideEffects) { var lastPlacedIndex = 0; var newIdx = 0; var nextOldFiber = null; + var knownKeys = null; var step = newChildren.next(); - for (; oldFiber !== null && !step.done; newIdx++, step = newChildren.next()) { + { + knownKeys = warnOnInvalidKey(step.value, knownKeys, returnFiber); + } + + for (; oldFiber !== null && !step.done; newIdx++, step = newChildren.next(), knownKeys = warnOnInvalidKey(step.value, knownKeys, returnFiber) ) { if (oldFiber.index > newIdx) { nextOldFiber = oldFiber; oldFiber = null; @@ -6249,7 +6245,7 @@ function createChildReconciler(shouldTrackSideEffects) { if (oldFiber === null) { // If we don't have any more existing children we can choose a fast path // since the rest will all be insertions. - for (; !step.done; newIdx++, step = newChildren.next()) { + for (; !step.done; newIdx++, step = newChildren.next(), knownKeys = warnOnInvalidKey(step.value, knownKeys, returnFiber) ) { var _newFiber3 = createChild(returnFiber, step.value, lanes, debugInfo); if (_newFiber3 === null) { @@ -6274,7 +6270,7 @@ function createChildReconciler(shouldTrackSideEffects) { var existingChildren = mapRemainingChildren(oldFiber); // Keep scanning and use the map to restore deleted items as moves. - for (; !step.done; newIdx++, step = newChildren.next()) { + for (; !step.done; newIdx++, step = newChildren.next(), knownKeys = warnOnInvalidKey(step.value, knownKeys, returnFiber) ) { var _newFiber4 = updateFromMap(existingChildren, returnFiber, newIdx, step.value, lanes, debugInfo); if (_newFiber4 !== null) { @@ -22990,7 +22986,7 @@ identifierPrefix, onUncaughtError, onCaughtError, onRecoverableError, transition return root; } -var ReactVersion = '19.0.0-canary-66405eaa'; +var ReactVersion = '19.0.0-canary-c4e3bea9'; /* * The `'' + value` pattern (used in perf-sensitive code) throws for Symbol diff --git a/compiled-rn/facebook-fbsource/xplat/js/RKJSModules/vendor/react-test-renderer/cjs/ReactTestRenderer-prod.js b/compiled-rn/facebook-fbsource/xplat/js/RKJSModules/vendor/react-test-renderer/cjs/ReactTestRenderer-prod.js index 15d6f529dbd8b..c2e1385d2c0c9 100644 --- a/compiled-rn/facebook-fbsource/xplat/js/RKJSModules/vendor/react-test-renderer/cjs/ReactTestRenderer-prod.js +++ b/compiled-rn/facebook-fbsource/xplat/js/RKJSModules/vendor/react-test-renderer/cjs/ReactTestRenderer-prod.js @@ -7,7 +7,7 @@ * @noflow * @nolint * @preventMunge - * @generated SignedSource<> + * @generated SignedSource<<8230647a80c4b86b8cf8384768883557>> */ "use strict"; @@ -1825,7 +1825,7 @@ function createChildReconciler(shouldTrackSideEffects) { nextOldFiber = null, step = newChildrenIterable.next(); null !== oldFiber && !step.done; - newIdx++, step = newChildrenIterable.next() + newIdx++, step = newChildrenIterable.next(), null ) { oldFiber.index > newIdx ? ((nextOldFiber = oldFiber), (oldFiber = null)) @@ -1849,7 +1849,7 @@ function createChildReconciler(shouldTrackSideEffects) { if (step.done) return deleteRemainingChildren(returnFiber, oldFiber), iteratorFn; if (null === oldFiber) { - for (; !step.done; newIdx++, step = newChildrenIterable.next()) + for (; !step.done; newIdx++, step = newChildrenIterable.next(), null) (step = createChild(returnFiber, step.value, lanes)), null !== step && ((currentFirstChild = placeChild(step, currentFirstChild, newIdx)), @@ -1862,7 +1862,7 @@ function createChildReconciler(shouldTrackSideEffects) { for ( oldFiber = mapRemainingChildren(oldFiber); !step.done; - newIdx++, step = newChildrenIterable.next() + newIdx++, step = newChildrenIterable.next(), null ) (step = updateFromMap(oldFiber, returnFiber, newIdx, step.value, lanes)), null !== step && @@ -9144,7 +9144,7 @@ var devToolsConfig$jscomp$inline_1019 = { throw Error("TestRenderer does not support findFiberByHostInstance()"); }, bundleType: 0, - version: "19.0.0-canary-7a48fce4", + version: "19.0.0-canary-a8200c0a", rendererPackageName: "react-test-renderer" }; var internals$jscomp$inline_1238 = { @@ -9175,7 +9175,7 @@ var internals$jscomp$inline_1238 = { scheduleRoot: null, setRefreshHandler: null, getCurrentFiber: null, - reconcilerVersion: "19.0.0-canary-7a48fce4" + reconcilerVersion: "19.0.0-canary-a8200c0a" }; if ("undefined" !== typeof __REACT_DEVTOOLS_GLOBAL_HOOK__) { var hook$jscomp$inline_1239 = __REACT_DEVTOOLS_GLOBAL_HOOK__; diff --git a/compiled-rn/facebook-fbsource/xplat/js/RKJSModules/vendor/react-test-renderer/cjs/ReactTestRenderer-profiling.js b/compiled-rn/facebook-fbsource/xplat/js/RKJSModules/vendor/react-test-renderer/cjs/ReactTestRenderer-profiling.js index 78892556831a9..75e1e7d7a0772 100644 --- a/compiled-rn/facebook-fbsource/xplat/js/RKJSModules/vendor/react-test-renderer/cjs/ReactTestRenderer-profiling.js +++ b/compiled-rn/facebook-fbsource/xplat/js/RKJSModules/vendor/react-test-renderer/cjs/ReactTestRenderer-profiling.js @@ -7,7 +7,7 @@ * @noflow * @nolint * @preventMunge - * @generated SignedSource<<9206ca0f6781a4c840d6d393f26b3429>> + * @generated SignedSource<<9f8b5b89043962a79b6b2123a526bf46>> */ "use strict"; @@ -1913,7 +1913,7 @@ function createChildReconciler(shouldTrackSideEffects) { nextOldFiber = null, step = newChildrenIterable.next(); null !== oldFiber && !step.done; - newIdx++, step = newChildrenIterable.next() + newIdx++, step = newChildrenIterable.next(), null ) { oldFiber.index > newIdx ? ((nextOldFiber = oldFiber), (oldFiber = null)) @@ -1937,7 +1937,7 @@ function createChildReconciler(shouldTrackSideEffects) { if (step.done) return deleteRemainingChildren(returnFiber, oldFiber), iteratorFn; if (null === oldFiber) { - for (; !step.done; newIdx++, step = newChildrenIterable.next()) + for (; !step.done; newIdx++, step = newChildrenIterable.next(), null) (step = createChild(returnFiber, step.value, lanes)), null !== step && ((currentFirstChild = placeChild(step, currentFirstChild, newIdx)), @@ -1950,7 +1950,7 @@ function createChildReconciler(shouldTrackSideEffects) { for ( oldFiber = mapRemainingChildren(oldFiber); !step.done; - newIdx++, step = newChildrenIterable.next() + newIdx++, step = newChildrenIterable.next(), null ) (step = updateFromMap(oldFiber, returnFiber, newIdx, step.value, lanes)), null !== step && @@ -9760,7 +9760,7 @@ var devToolsConfig$jscomp$inline_1101 = { throw Error("TestRenderer does not support findFiberByHostInstance()"); }, bundleType: 0, - version: "19.0.0-canary-39a6938a", + version: "19.0.0-canary-359342b1", rendererPackageName: "react-test-renderer" }; (function (internals) { @@ -9804,7 +9804,7 @@ var devToolsConfig$jscomp$inline_1101 = { scheduleRoot: null, setRefreshHandler: null, getCurrentFiber: null, - reconcilerVersion: "19.0.0-canary-39a6938a" + reconcilerVersion: "19.0.0-canary-359342b1" }); exports._Scheduler = Scheduler; exports.act = act; diff --git a/compiled-rn/facebook-fbsource/xplat/js/RKJSModules/vendor/react/cjs/JSXDEVRuntime-dev.js b/compiled-rn/facebook-fbsource/xplat/js/RKJSModules/vendor/react/cjs/JSXDEVRuntime-dev.js index c6f601d067d08..b637962008d68 100644 --- a/compiled-rn/facebook-fbsource/xplat/js/RKJSModules/vendor/react/cjs/JSXDEVRuntime-dev.js +++ b/compiled-rn/facebook-fbsource/xplat/js/RKJSModules/vendor/react/cjs/JSXDEVRuntime-dev.js @@ -7,7 +7,7 @@ * @noflow * @nolint * @preventMunge - * @generated SignedSource<<8f878889d9995d2ae240b302c52058bd>> + * @generated SignedSource<> */ 'use strict'; @@ -1304,11 +1304,14 @@ function validateChildKeys(node, parentType) { // but now we print a separate warning for them later. if (iteratorFn !== node.entries) { var iterator = iteratorFn.call(node); - var step; - while (!(step = iterator.next()).done) { - if (isValidElement(step.value)) { - validateExplicitKey(step.value, parentType); + if (iterator !== node) { + var step; + + while (!(step = iterator.next()).done) { + if (isValidElement(step.value)) { + validateExplicitKey(step.value, parentType); + } } } } diff --git a/compiled-rn/facebook-fbsource/xplat/js/RKJSModules/vendor/react/cjs/JSXRuntime-dev.js b/compiled-rn/facebook-fbsource/xplat/js/RKJSModules/vendor/react/cjs/JSXRuntime-dev.js index 0cc9c98978f82..7c2ac70b2200e 100644 --- a/compiled-rn/facebook-fbsource/xplat/js/RKJSModules/vendor/react/cjs/JSXRuntime-dev.js +++ b/compiled-rn/facebook-fbsource/xplat/js/RKJSModules/vendor/react/cjs/JSXRuntime-dev.js @@ -7,7 +7,7 @@ * @noflow * @nolint * @preventMunge - * @generated SignedSource<<63334719117bc7e81815150b27588000>> + * @generated SignedSource<<6786f79c50baa1d713a06b4ed12afb60>> */ 'use strict'; @@ -1328,11 +1328,14 @@ function validateChildKeys(node, parentType) { // but now we print a separate warning for them later. if (iteratorFn !== node.entries) { var iterator = iteratorFn.call(node); - var step; - while (!(step = iterator.next()).done) { - if (isValidElement(step.value)) { - validateExplicitKey(step.value, parentType); + if (iterator !== node) { + var step; + + while (!(step = iterator.next()).done) { + if (isValidElement(step.value)) { + validateExplicitKey(step.value, parentType); + } } } } diff --git a/compiled-rn/facebook-fbsource/xplat/js/RKJSModules/vendor/react/cjs/React-dev.js b/compiled-rn/facebook-fbsource/xplat/js/RKJSModules/vendor/react/cjs/React-dev.js index 7d765da45b958..c396e4d31d401 100644 --- a/compiled-rn/facebook-fbsource/xplat/js/RKJSModules/vendor/react/cjs/React-dev.js +++ b/compiled-rn/facebook-fbsource/xplat/js/RKJSModules/vendor/react/cjs/React-dev.js @@ -7,7 +7,7 @@ * @noflow * @nolint * @preventMunge - * @generated SignedSource<<1ccd58cd787da0b40cbf5543503953db>> + * @generated SignedSource<<745c28cba28ff3a4a3a391cfdfdd1c1b>> */ 'use strict'; @@ -27,7 +27,7 @@ if ( } var dynamicFlagsUntyped = require('ReactNativeInternalFeatureFlags'); -var ReactVersion = '19.0.0-canary-c627bf44'; +var ReactVersion = '19.0.0-canary-e8808e1d'; // ATTENTION // When adding new symbols to this file, @@ -1889,11 +1889,14 @@ function validateChildKeys(node, parentType) { // but now we print a separate warning for them later. if (iteratorFn !== node.entries) { var iterator = iteratorFn.call(node); - var step; - while (!(step = iterator.next()).done) { - if (isValidElement(step.value)) { - validateExplicitKey(step.value, parentType); + if (iterator !== node) { + var step; + + while (!(step = iterator.next()).done) { + if (isValidElement(step.value)) { + validateExplicitKey(step.value, parentType); + } } } } diff --git a/compiled-rn/facebook-fbsource/xplat/js/react-native-github/Libraries/Renderer/REVISION b/compiled-rn/facebook-fbsource/xplat/js/react-native-github/Libraries/Renderer/REVISION index f84466e1b800f..d7ae26c1bbb0d 100644 --- a/compiled-rn/facebook-fbsource/xplat/js/react-native-github/Libraries/Renderer/REVISION +++ b/compiled-rn/facebook-fbsource/xplat/js/react-native-github/Libraries/Renderer/REVISION @@ -1 +1 @@ -ea26e38e33bffeba1ecc42688d7e8cd7e0da1c02 +368202181e772d411b2445930aea1edd9428b09b diff --git a/compiled-rn/facebook-fbsource/xplat/js/react-native-github/Libraries/Renderer/implementations/ReactFabric-dev.fb.js b/compiled-rn/facebook-fbsource/xplat/js/react-native-github/Libraries/Renderer/implementations/ReactFabric-dev.fb.js index c4cd957d0f3a0..00c7f089ac591 100644 --- a/compiled-rn/facebook-fbsource/xplat/js/react-native-github/Libraries/Renderer/implementations/ReactFabric-dev.fb.js +++ b/compiled-rn/facebook-fbsource/xplat/js/react-native-github/Libraries/Renderer/implementations/ReactFabric-dev.fb.js @@ -7,7 +7,7 @@ * @noflow * @nolint * @preventMunge - * @generated SignedSource<<1a8fdf80e78f9d6a4a8bccd8d1a9a735>> + * @generated SignedSource<<6bbaf37a7e6d0c6b86bd687aa4e09ebe>> */ 'use strict'; @@ -9101,45 +9101,36 @@ function createChildReconciler(shouldTrackSideEffects) { throw new Error('An object is not an iterable. This error is likely caused by a bug in ' + 'React. Please file an issue.'); } - { - // We don't support rendering Generators because it's a mutation. - // See https://github.com/facebook/react/issues/12995 - if (typeof Symbol === 'function' && // $FlowFixMe[prop-missing] Flow doesn't know about toStringTag - newChildrenIterable[Symbol.toStringTag] === 'Generator') { - if (!didWarnAboutGenerators) { - error('Using Generators as children is unsupported and will likely yield ' + 'unexpected results because enumerating a generator mutates it. ' + 'You may convert it to an array with `Array.from()` or the ' + '`[...spread]` operator before rendering. Keep in mind ' + 'you might need to polyfill these features for older browsers.'); - } - - didWarnAboutGenerators = true; - } // Warn about using Maps as children + var newChildren = iteratorFn.call(newChildrenIterable); + { + if (newChildren === newChildrenIterable) { + // We don't support rendering Generators as props because it's a mutation. + // See https://github.com/facebook/react/issues/12995 + // We do support generators if they were created by a GeneratorFunction component + // as its direct child since we can recreate those by rerendering the component + // as needed. + var isGeneratorComponent = returnFiber.tag === FunctionComponent && // $FlowFixMe[method-unbinding] + Object.prototype.toString.call(returnFiber.type) === '[object GeneratorFunction]' && // $FlowFixMe[method-unbinding] + Object.prototype.toString.call(newChildren) === '[object Generator]'; + + if (!isGeneratorComponent) { + if (!didWarnAboutGenerators) { + error('Using Iterators as children is unsupported and will likely yield ' + 'unexpected results because enumerating a generator mutates it. ' + 'You may convert it to an array with `Array.from()` or the ' + '`[...spread]` operator before rendering. You can also use an ' + 'Iterable that can iterate multiple times over the same items.'); + } - if (newChildrenIterable.entries === iteratorFn) { + didWarnAboutGenerators = true; + } + } else if (newChildrenIterable.entries === iteratorFn) { + // Warn about using Maps as children if (!didWarnAboutMaps) { error('Using Maps as children is not supported. ' + 'Use an array of keyed ReactElements instead.'); - } - - didWarnAboutMaps = true; - } // First, validate keys. - // We'll get a different iterator later for the main pass. - - var _newChildren = iteratorFn.call(newChildrenIterable); - - if (_newChildren) { - var knownKeys = null; - - var _step = _newChildren.next(); - - for (; !_step.done; _step = _newChildren.next()) { - var child = _step.value; - knownKeys = warnOnInvalidKey(child, knownKeys, returnFiber); + didWarnAboutMaps = true; } } } - var newChildren = iteratorFn.call(newChildrenIterable); - if (newChildren == null) { throw new Error('An iterable object provided no iterator.'); } @@ -9150,9 +9141,14 @@ function createChildReconciler(shouldTrackSideEffects) { var lastPlacedIndex = 0; var newIdx = 0; var nextOldFiber = null; + var knownKeys = null; var step = newChildren.next(); - for (; oldFiber !== null && !step.done; newIdx++, step = newChildren.next()) { + { + knownKeys = warnOnInvalidKey(step.value, knownKeys, returnFiber); + } + + for (; oldFiber !== null && !step.done; newIdx++, step = newChildren.next(), knownKeys = warnOnInvalidKey(step.value, knownKeys, returnFiber) ) { if (oldFiber.index > newIdx) { nextOldFiber = oldFiber; oldFiber = null; @@ -9209,7 +9205,7 @@ function createChildReconciler(shouldTrackSideEffects) { if (oldFiber === null) { // If we don't have any more existing children we can choose a fast path // since the rest will all be insertions. - for (; !step.done; newIdx++, step = newChildren.next()) { + for (; !step.done; newIdx++, step = newChildren.next(), knownKeys = warnOnInvalidKey(step.value, knownKeys, returnFiber) ) { var _newFiber3 = createChild(returnFiber, step.value, lanes, debugInfo); if (_newFiber3 === null) { @@ -9234,7 +9230,7 @@ function createChildReconciler(shouldTrackSideEffects) { var existingChildren = mapRemainingChildren(oldFiber); // Keep scanning and use the map to restore deleted items as moves. - for (; !step.done; newIdx++, step = newChildren.next()) { + for (; !step.done; newIdx++, step = newChildren.next(), knownKeys = warnOnInvalidKey(step.value, knownKeys, returnFiber) ) { var _newFiber4 = updateFromMap(existingChildren, returnFiber, newIdx, step.value, lanes, debugInfo); if (_newFiber4 !== null) { @@ -26060,7 +26056,7 @@ identifierPrefix, onUncaughtError, onCaughtError, onRecoverableError, transition return root; } -var ReactVersion = '19.0.0-canary-e42cf623'; +var ReactVersion = '19.0.0-canary-b83624af'; /* * The `'' + value` pattern (used in perf-sensitive code) throws for Symbol diff --git a/compiled-rn/facebook-fbsource/xplat/js/react-native-github/Libraries/Renderer/implementations/ReactFabric-prod.fb.js b/compiled-rn/facebook-fbsource/xplat/js/react-native-github/Libraries/Renderer/implementations/ReactFabric-prod.fb.js index d42407ff200f9..f95f11a2b2830 100644 --- a/compiled-rn/facebook-fbsource/xplat/js/react-native-github/Libraries/Renderer/implementations/ReactFabric-prod.fb.js +++ b/compiled-rn/facebook-fbsource/xplat/js/react-native-github/Libraries/Renderer/implementations/ReactFabric-prod.fb.js @@ -7,7 +7,7 @@ * @noflow * @nolint * @preventMunge - * @generated SignedSource<> + * @generated SignedSource<<885ed33c17f9bf322d3f754c50d26ed9>> */ "use strict"; @@ -3350,7 +3350,7 @@ function createChildReconciler(shouldTrackSideEffects) { nextOldFiber = null, step = newChildrenIterable.next(); null !== oldFiber && !step.done; - newIdx++, step = newChildrenIterable.next() + newIdx++, step = newChildrenIterable.next(), null ) { oldFiber.index > newIdx ? ((nextOldFiber = oldFiber), (oldFiber = null)) @@ -3374,7 +3374,7 @@ function createChildReconciler(shouldTrackSideEffects) { if (step.done) return deleteRemainingChildren(returnFiber, oldFiber), iteratorFn; if (null === oldFiber) { - for (; !step.done; newIdx++, step = newChildrenIterable.next()) + for (; !step.done; newIdx++, step = newChildrenIterable.next(), null) (step = createChild(returnFiber, step.value, lanes)), null !== step && ((currentFirstChild = placeChild(step, currentFirstChild, newIdx)), @@ -3387,7 +3387,7 @@ function createChildReconciler(shouldTrackSideEffects) { for ( oldFiber = mapRemainingChildren(oldFiber); !step.done; - newIdx++, step = newChildrenIterable.next() + newIdx++, step = newChildrenIterable.next(), null ) (step = updateFromMap(oldFiber, returnFiber, newIdx, step.value, lanes)), null !== step && @@ -10602,7 +10602,7 @@ var roots = new Map(), devToolsConfig$jscomp$inline_1099 = { findFiberByHostInstance: getInstanceFromNode, bundleType: 0, - version: "19.0.0-canary-7f7baf16", + version: "19.0.0-canary-d7b022bb", rendererPackageName: "react-native-renderer", rendererConfig: { getInspectorDataForInstance: getInspectorDataForInstance, @@ -10645,7 +10645,7 @@ var internals$jscomp$inline_1366 = { scheduleRoot: null, setRefreshHandler: null, getCurrentFiber: null, - reconcilerVersion: "19.0.0-canary-7f7baf16" + reconcilerVersion: "19.0.0-canary-d7b022bb" }; if ("undefined" !== typeof __REACT_DEVTOOLS_GLOBAL_HOOK__) { var hook$jscomp$inline_1367 = __REACT_DEVTOOLS_GLOBAL_HOOK__; diff --git a/compiled-rn/facebook-fbsource/xplat/js/react-native-github/Libraries/Renderer/implementations/ReactFabric-profiling.fb.js b/compiled-rn/facebook-fbsource/xplat/js/react-native-github/Libraries/Renderer/implementations/ReactFabric-profiling.fb.js index b8bf91b0744db..20f974e88cd2b 100644 --- a/compiled-rn/facebook-fbsource/xplat/js/react-native-github/Libraries/Renderer/implementations/ReactFabric-profiling.fb.js +++ b/compiled-rn/facebook-fbsource/xplat/js/react-native-github/Libraries/Renderer/implementations/ReactFabric-profiling.fb.js @@ -7,7 +7,7 @@ * @noflow * @nolint * @preventMunge - * @generated SignedSource<<64acec7be24561ecbf6d2eaf55e55d0a>> + * @generated SignedSource<<0fd40d36a058297c5f28d3505e638983>> */ "use strict"; @@ -3472,7 +3472,7 @@ function createChildReconciler(shouldTrackSideEffects) { nextOldFiber = null, step = newChildrenIterable.next(); null !== oldFiber && !step.done; - newIdx++, step = newChildrenIterable.next() + newIdx++, step = newChildrenIterable.next(), null ) { oldFiber.index > newIdx ? ((nextOldFiber = oldFiber), (oldFiber = null)) @@ -3496,7 +3496,7 @@ function createChildReconciler(shouldTrackSideEffects) { if (step.done) return deleteRemainingChildren(returnFiber, oldFiber), iteratorFn; if (null === oldFiber) { - for (; !step.done; newIdx++, step = newChildrenIterable.next()) + for (; !step.done; newIdx++, step = newChildrenIterable.next(), null) (step = createChild(returnFiber, step.value, lanes)), null !== step && ((currentFirstChild = placeChild(step, currentFirstChild, newIdx)), @@ -3509,7 +3509,7 @@ function createChildReconciler(shouldTrackSideEffects) { for ( oldFiber = mapRemainingChildren(oldFiber); !step.done; - newIdx++, step = newChildrenIterable.next() + newIdx++, step = newChildrenIterable.next(), null ) (step = updateFromMap(oldFiber, returnFiber, newIdx, step.value, lanes)), null !== step && @@ -11307,7 +11307,7 @@ var roots = new Map(), devToolsConfig$jscomp$inline_1179 = { findFiberByHostInstance: getInstanceFromNode, bundleType: 0, - version: "19.0.0-canary-ef6bcf29", + version: "19.0.0-canary-9e21665c", rendererPackageName: "react-native-renderer", rendererConfig: { getInspectorDataForInstance: getInspectorDataForInstance, @@ -11363,7 +11363,7 @@ var roots = new Map(), scheduleRoot: null, setRefreshHandler: null, getCurrentFiber: null, - reconcilerVersion: "19.0.0-canary-ef6bcf29" + reconcilerVersion: "19.0.0-canary-9e21665c" }); exports.createPortal = function (children, containerTag) { return createPortal$1( diff --git a/compiled-rn/facebook-fbsource/xplat/js/react-native-github/Libraries/Renderer/implementations/ReactNativeRenderer-dev.fb.js b/compiled-rn/facebook-fbsource/xplat/js/react-native-github/Libraries/Renderer/implementations/ReactNativeRenderer-dev.fb.js index 55cd113e1eab5..0e227c6f612be 100644 --- a/compiled-rn/facebook-fbsource/xplat/js/react-native-github/Libraries/Renderer/implementations/ReactNativeRenderer-dev.fb.js +++ b/compiled-rn/facebook-fbsource/xplat/js/react-native-github/Libraries/Renderer/implementations/ReactNativeRenderer-dev.fb.js @@ -7,7 +7,7 @@ * @noflow * @nolint * @preventMunge - * @generated SignedSource<<0ce01fc662f6de8232355aded350d529>> + * @generated SignedSource<<1c5ee0ee0fef4e85b317999b53699b5f>> */ 'use strict'; @@ -9340,45 +9340,36 @@ function createChildReconciler(shouldTrackSideEffects) { throw new Error('An object is not an iterable. This error is likely caused by a bug in ' + 'React. Please file an issue.'); } - { - // We don't support rendering Generators because it's a mutation. - // See https://github.com/facebook/react/issues/12995 - if (typeof Symbol === 'function' && // $FlowFixMe[prop-missing] Flow doesn't know about toStringTag - newChildrenIterable[Symbol.toStringTag] === 'Generator') { - if (!didWarnAboutGenerators) { - error('Using Generators as children is unsupported and will likely yield ' + 'unexpected results because enumerating a generator mutates it. ' + 'You may convert it to an array with `Array.from()` or the ' + '`[...spread]` operator before rendering. Keep in mind ' + 'you might need to polyfill these features for older browsers.'); - } - - didWarnAboutGenerators = true; - } // Warn about using Maps as children + var newChildren = iteratorFn.call(newChildrenIterable); + { + if (newChildren === newChildrenIterable) { + // We don't support rendering Generators as props because it's a mutation. + // See https://github.com/facebook/react/issues/12995 + // We do support generators if they were created by a GeneratorFunction component + // as its direct child since we can recreate those by rerendering the component + // as needed. + var isGeneratorComponent = returnFiber.tag === FunctionComponent && // $FlowFixMe[method-unbinding] + Object.prototype.toString.call(returnFiber.type) === '[object GeneratorFunction]' && // $FlowFixMe[method-unbinding] + Object.prototype.toString.call(newChildren) === '[object Generator]'; + + if (!isGeneratorComponent) { + if (!didWarnAboutGenerators) { + error('Using Iterators as children is unsupported and will likely yield ' + 'unexpected results because enumerating a generator mutates it. ' + 'You may convert it to an array with `Array.from()` or the ' + '`[...spread]` operator before rendering. You can also use an ' + 'Iterable that can iterate multiple times over the same items.'); + } - if (newChildrenIterable.entries === iteratorFn) { + didWarnAboutGenerators = true; + } + } else if (newChildrenIterable.entries === iteratorFn) { + // Warn about using Maps as children if (!didWarnAboutMaps) { error('Using Maps as children is not supported. ' + 'Use an array of keyed ReactElements instead.'); - } - - didWarnAboutMaps = true; - } // First, validate keys. - // We'll get a different iterator later for the main pass. - - var _newChildren = iteratorFn.call(newChildrenIterable); - - if (_newChildren) { - var knownKeys = null; - - var _step = _newChildren.next(); - - for (; !_step.done; _step = _newChildren.next()) { - var child = _step.value; - knownKeys = warnOnInvalidKey(child, knownKeys, returnFiber); + didWarnAboutMaps = true; } } } - var newChildren = iteratorFn.call(newChildrenIterable); - if (newChildren == null) { throw new Error('An iterable object provided no iterator.'); } @@ -9389,9 +9380,14 @@ function createChildReconciler(shouldTrackSideEffects) { var lastPlacedIndex = 0; var newIdx = 0; var nextOldFiber = null; + var knownKeys = null; var step = newChildren.next(); - for (; oldFiber !== null && !step.done; newIdx++, step = newChildren.next()) { + { + knownKeys = warnOnInvalidKey(step.value, knownKeys, returnFiber); + } + + for (; oldFiber !== null && !step.done; newIdx++, step = newChildren.next(), knownKeys = warnOnInvalidKey(step.value, knownKeys, returnFiber) ) { if (oldFiber.index > newIdx) { nextOldFiber = oldFiber; oldFiber = null; @@ -9448,7 +9444,7 @@ function createChildReconciler(shouldTrackSideEffects) { if (oldFiber === null) { // If we don't have any more existing children we can choose a fast path // since the rest will all be insertions. - for (; !step.done; newIdx++, step = newChildren.next()) { + for (; !step.done; newIdx++, step = newChildren.next(), knownKeys = warnOnInvalidKey(step.value, knownKeys, returnFiber) ) { var _newFiber3 = createChild(returnFiber, step.value, lanes, debugInfo); if (_newFiber3 === null) { @@ -9473,7 +9469,7 @@ function createChildReconciler(shouldTrackSideEffects) { var existingChildren = mapRemainingChildren(oldFiber); // Keep scanning and use the map to restore deleted items as moves. - for (; !step.done; newIdx++, step = newChildren.next()) { + for (; !step.done; newIdx++, step = newChildren.next(), knownKeys = warnOnInvalidKey(step.value, knownKeys, returnFiber) ) { var _newFiber4 = updateFromMap(existingChildren, returnFiber, newIdx, step.value, lanes, debugInfo); if (_newFiber4 !== null) { @@ -26475,7 +26471,7 @@ identifierPrefix, onUncaughtError, onCaughtError, onRecoverableError, transition return root; } -var ReactVersion = '19.0.0-canary-852c4872'; +var ReactVersion = '19.0.0-canary-f6aae78f'; /* * The `'' + value` pattern (used in perf-sensitive code) throws for Symbol diff --git a/compiled-rn/facebook-fbsource/xplat/js/react-native-github/Libraries/Renderer/implementations/ReactNativeRenderer-prod.fb.js b/compiled-rn/facebook-fbsource/xplat/js/react-native-github/Libraries/Renderer/implementations/ReactNativeRenderer-prod.fb.js index 5ee88e7cd9b00..ace87d5eca2c5 100644 --- a/compiled-rn/facebook-fbsource/xplat/js/react-native-github/Libraries/Renderer/implementations/ReactNativeRenderer-prod.fb.js +++ b/compiled-rn/facebook-fbsource/xplat/js/react-native-github/Libraries/Renderer/implementations/ReactNativeRenderer-prod.fb.js @@ -7,7 +7,7 @@ * @noflow * @nolint * @preventMunge - * @generated SignedSource<<40e33e67d4c6fd0373352fbe892a02dc>> + * @generated SignedSource<<559fea30e60deb383163e9ed4cb86c78>> */ "use strict"; @@ -3403,7 +3403,7 @@ function createChildReconciler(shouldTrackSideEffects) { nextOldFiber = null, step = newChildrenIterable.next(); null !== oldFiber && !step.done; - newIdx++, step = newChildrenIterable.next() + newIdx++, step = newChildrenIterable.next(), null ) { oldFiber.index > newIdx ? ((nextOldFiber = oldFiber), (oldFiber = null)) @@ -3427,7 +3427,7 @@ function createChildReconciler(shouldTrackSideEffects) { if (step.done) return deleteRemainingChildren(returnFiber, oldFiber), iteratorFn; if (null === oldFiber) { - for (; !step.done; newIdx++, step = newChildrenIterable.next()) + for (; !step.done; newIdx++, step = newChildrenIterable.next(), null) (step = createChild(returnFiber, step.value, lanes)), null !== step && ((currentFirstChild = placeChild(step, currentFirstChild, newIdx)), @@ -3440,7 +3440,7 @@ function createChildReconciler(shouldTrackSideEffects) { for ( oldFiber = mapRemainingChildren(oldFiber); !step.done; - newIdx++, step = newChildrenIterable.next() + newIdx++, step = newChildrenIterable.next(), null ) (step = updateFromMap(oldFiber, returnFiber, newIdx, step.value, lanes)), null !== step && @@ -10824,7 +10824,7 @@ var roots = new Map(), devToolsConfig$jscomp$inline_1168 = { findFiberByHostInstance: getInstanceFromTag, bundleType: 0, - version: "19.0.0-canary-7fc44ecb", + version: "19.0.0-canary-72179424", rendererPackageName: "react-native-renderer", rendererConfig: { getInspectorDataForInstance: getInspectorDataForInstance, @@ -10867,7 +10867,7 @@ var internals$jscomp$inline_1452 = { scheduleRoot: null, setRefreshHandler: null, getCurrentFiber: null, - reconcilerVersion: "19.0.0-canary-7fc44ecb" + reconcilerVersion: "19.0.0-canary-72179424" }; if ("undefined" !== typeof __REACT_DEVTOOLS_GLOBAL_HOOK__) { var hook$jscomp$inline_1453 = __REACT_DEVTOOLS_GLOBAL_HOOK__; diff --git a/compiled-rn/facebook-fbsource/xplat/js/react-native-github/Libraries/Renderer/implementations/ReactNativeRenderer-profiling.fb.js b/compiled-rn/facebook-fbsource/xplat/js/react-native-github/Libraries/Renderer/implementations/ReactNativeRenderer-profiling.fb.js index 836fb391c14c6..f925082c5473c 100644 --- a/compiled-rn/facebook-fbsource/xplat/js/react-native-github/Libraries/Renderer/implementations/ReactNativeRenderer-profiling.fb.js +++ b/compiled-rn/facebook-fbsource/xplat/js/react-native-github/Libraries/Renderer/implementations/ReactNativeRenderer-profiling.fb.js @@ -7,7 +7,7 @@ * @noflow * @nolint * @preventMunge - * @generated SignedSource<> + * @generated SignedSource<<677f52c0fc1c027786c2d7914509109d>> */ "use strict"; @@ -3525,7 +3525,7 @@ function createChildReconciler(shouldTrackSideEffects) { nextOldFiber = null, step = newChildrenIterable.next(); null !== oldFiber && !step.done; - newIdx++, step = newChildrenIterable.next() + newIdx++, step = newChildrenIterable.next(), null ) { oldFiber.index > newIdx ? ((nextOldFiber = oldFiber), (oldFiber = null)) @@ -3549,7 +3549,7 @@ function createChildReconciler(shouldTrackSideEffects) { if (step.done) return deleteRemainingChildren(returnFiber, oldFiber), iteratorFn; if (null === oldFiber) { - for (; !step.done; newIdx++, step = newChildrenIterable.next()) + for (; !step.done; newIdx++, step = newChildrenIterable.next(), null) (step = createChild(returnFiber, step.value, lanes)), null !== step && ((currentFirstChild = placeChild(step, currentFirstChild, newIdx)), @@ -3562,7 +3562,7 @@ function createChildReconciler(shouldTrackSideEffects) { for ( oldFiber = mapRemainingChildren(oldFiber); !step.done; - newIdx++, step = newChildrenIterable.next() + newIdx++, step = newChildrenIterable.next(), null ) (step = updateFromMap(oldFiber, returnFiber, newIdx, step.value, lanes)), null !== step && @@ -11530,7 +11530,7 @@ var roots = new Map(), devToolsConfig$jscomp$inline_1248 = { findFiberByHostInstance: getInstanceFromTag, bundleType: 0, - version: "19.0.0-canary-b6bdb4e2", + version: "19.0.0-canary-d8b54028", rendererPackageName: "react-native-renderer", rendererConfig: { getInspectorDataForInstance: getInspectorDataForInstance, @@ -11586,7 +11586,7 @@ var roots = new Map(), scheduleRoot: null, setRefreshHandler: null, getCurrentFiber: null, - reconcilerVersion: "19.0.0-canary-b6bdb4e2" + reconcilerVersion: "19.0.0-canary-d8b54028" }); exports.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED = { computeComponentStackForErrorReporting: function (reactTag) {