Summary:
Explain the **motivation** for making this change. What existing problem does the pull request solve?

This change is required when you try to set a focus on a view that doesn't exist and thus cannot be focused. In my specific use case, this occurred when trying to set a focus on a list item in a setInterval when the View (with the specific list item) had been popped. The while loop ran infinitely (eventually freezing the app) since the rootView doesn't exist. This adds that check and breaks out if so.

All obj-c tests ran successfully.

dlowder-salesforce
Closes https://github.com/facebook/react-native/pull/12073

Differential Revision: D4468989

Pulled By: ericvicenti

fbshipit-source-id: 7926c887035722c983c41cb6b6d9df567010c2ee
This commit is contained in:
Eric Vicenti 2017-01-26 09:41:20 -08:00 коммит произвёл Facebook Github Bot
Родитель 3ab9137b9e
Коммит 65513e501a
1 изменённых файлов: 3 добавлений и 1 удалений

Просмотреть файл

@ -173,9 +173,11 @@ RCT_NOT_IMPLEMENTED(- (instancetype)initWithCoder:unused)
if (hasTVPreferredFocus) {
dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(1.0 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
UIView *rootview = self;
while(![rootview isReactRootView]) {
while (![rootview isReactRootView] && rootview != nil) {
rootview = [rootview superview];
}
if (rootview == nil) return;
rootview = [rootview superview];
[(RCTRootView *)rootview setReactPreferredFocusedView:self];