-
Notifications
You must be signed in to change notification settings - Fork 24.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix red screen due to ref being undefined in PullRefreshViewAndroid #6489
Conversation
By analyzing the blame information on this pull request, we identified @jaysoo, @bestander and @janicduplessis to be potential reviewers. |
Thank you for your pull request and welcome to our community. We require contributors to sign our Contributor License Agreement, and we don't seem to have you on file. In order for us to review and merge your code, please sign up at https://code.facebook.com/cla - and if you have received this in error or have any questions, please drop us a line at cla@fb.com. Thanks! |
Thank you for signing our Contributor License Agreement. We can now accept your code for this (and any) Facebook open source project. Thanks! |
@@ -67,7 +67,7 @@ var PullToRefreshViewAndroid = React.createClass({ | |||
}, | |||
|
|||
setNativeProps: function(props) { | |||
return this.refs[NATIVE_REF].setNativeProps(props); | |||
return this.getInnerViewNode().setNativeProps(props); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you do the check here instead of doing it onRefresh
?
@thomdixon updated the pull request. |
1 similar comment
@thomdixon updated the pull request. |
@satya164 Done! Tests are failing because bestander/sinopia here on github can't be reached for some reason. Maybe you can run them again or run them locally? |
@thomdixon You can rebase on master to re-run the tests. |
|
cc @bestander The flow check seems to be failing due to some json files, which as I recall, was fixed with latest flow. |
Thanks, @satya164, I have scheduled a rerun with clear caches. |
This fixes the error `undefined is not an object (evaluating 'this.refs[NATIVE_REF].setNativeProps')`.
As requested by @satya164 :)
@@ -67,7 +67,8 @@ var PullToRefreshViewAndroid = React.createClass({ | |||
}, | |||
|
|||
setNativeProps: function(props) { | |||
return this.refs[NATIVE_REF].setNativeProps(props); | |||
let innerViewNode = this.getInnerViewNode(); | |||
return innerViewNode && innerViewNode.setNativeProps(props); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
When can innerViewNode
be null? We should understand what's going on here and make sure that it's valid for setNativeProps to be called when innerViewNode
is null, or instead fix whatever's calling setNativeProps at the wrong time.
This looks like it's patching a symptom and not fixing the root cause. If this is a semantically correct fix, let's merge it, but I want to be sure first. |
Fixed something similar for RefreshControl. The ref is null if the PullToRefreshViewAndroid gets unmounted during the onRefresh callback. |
@ide can we merge this, since you merged the iOS patch that basically does the same thing? Or would you like a revision? Thanks! |
Taking another look rn |
Thanks for the fix. We need support for asynchrony in React :/ @facebook-github-bot shipit |
Thanks for importing. If you are an FB employee go to Phabricator to review. |
@facebook-github-bot shipit |
Thanks for importing. If you are an FB employee go to Phabricator to review. |
d586daa
Summary:This fixes the error `undefined is not an object (evaluating 'this.refs[NATIVE_REF].setNativeProps')`, which seems to occur when the refresh fails (in our case due to CORS). ![screen shot 2016-03-16 at 12 23 52](https://cloud.githubusercontent.com/assets/461514/13826121/1f8b0aaa-eb73-11e5-81e3-b2c60e536bf0.png) Closes facebook#6489 Differential Revision: D3172217 fb-gh-sync-id: 5ba3b2653685888f5358ef32b01b441757eff7c8 fbshipit-source-id: 5ba3b2653685888f5358ef32b01b441757eff7c8
Summary:This fixes the error `undefined is not an object (evaluating 'this.refs[NATIVE_REF].setNativeProps')`, which seems to occur when the refresh fails (in our case due to CORS). ![screen shot 2016-03-16 at 12 23 52](https://cloud.githubusercontent.com/assets/461514/13826121/1f8b0aaa-eb73-11e5-81e3-b2c60e536bf0.png) Closes facebook#6489 Differential Revision: D3172217 fb-gh-sync-id: 5ba3b2653685888f5358ef32b01b441757eff7c8 fbshipit-source-id: 5ba3b2653685888f5358ef32b01b441757eff7c8
Summary:This fixes the error `undefined is not an object (evaluating 'this.refs[NATIVE_REF].setNativeProps')`, which seems to occur when the refresh fails (in our case due to CORS). ![screen shot 2016-03-16 at 12 23 52](https://cloud.githubusercontent.com/assets/461514/13826121/1f8b0aaa-eb73-11e5-81e3-b2c60e536bf0.png) Closes facebook#6489 Differential Revision: D3172217 fb-gh-sync-id: 5ba3b2653685888f5358ef32b01b441757eff7c8 fbshipit-source-id: 5ba3b2653685888f5358ef32b01b441757eff7c8
This fixes the error
undefined is not an object (evaluating 'this.refs[NATIVE_REF].setNativeProps')
, which seems to occur when the refresh fails (in our case due to CORS).