Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Remove usage of the ... operator in BackHandler
This usage currently causes BackHandler to silently become non-functional when a Symbol polyfill is used. Why? - The [...obj] operator implicitly calls the object's iterator to fill the array - react-native's internal Set polyfill has a load order issue that breaks it whenever a project uses a Symbol polyfill - This means that when BackHandler tries to [...set] a Set of subscriptions the result is always an empty array instead of an array of subscriptions Additionally it's worth noting that the current code is also wastefully inefficient as in order to reverse iterate over subscriptions it: - Clones the Set (which fills it by implicitly running the set's iterator) - Uses [...set] to convert the cloned set into an array (which also implicitly runs the iterator on the clone) - Finally reverses the order of the array This code fixes this problem by replacing the use of multiple Set instance iterators with use of `set.values()` which does not require the set's implicit iterator. Fixes facebook#11968
- Loading branch information