Skip to content
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

Closed
wants to merge 2 commits into from

Conversation

thomdixon
Copy link
Contributor

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

@facebook-github-bot
Copy link
Contributor

By analyzing the blame information on this pull request, we identified @jaysoo, @bestander and @janicduplessis to be potential reviewers.

@facebook-github-bot
Copy link
Contributor

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!

@facebook-github-bot
Copy link
Contributor

Thank you for signing our Contributor License Agreement. We can now accept your code for this (and any) Facebook open source project. Thanks!

@facebook-github-bot facebook-github-bot added the CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed. label Mar 17, 2016
@@ -67,7 +67,7 @@ var PullToRefreshViewAndroid = React.createClass({
},

setNativeProps: function(props) {
return this.refs[NATIVE_REF].setNativeProps(props);
return this.getInnerViewNode().setNativeProps(props);
Copy link
Contributor

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?

@facebook-github-bot
Copy link
Contributor

@thomdixon updated the pull request.

1 similar comment
@facebook-github-bot
Copy link
Contributor

@thomdixon updated the pull request.

@thomdixon
Copy link
Contributor Author

@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?

@satya164
Copy link
Contributor

satya164 commented Apr 4, 2016

@thomdixon You can rebase on master to re-run the tests.

@thomdixon
Copy link
Contributor Author

flow check is failing on some unrelated buck stuff. All other tests pass. Will run the tests again when I can. 🎱

@satya164
Copy link
Contributor

satya164 commented Apr 4, 2016

cc @bestander

The flow check seems to be failing due to some json files, which as I recall, was fixed with latest flow.

@bestander
Copy link
Contributor

Thanks, @satya164, I have scheduled a rerun with clear caches.
Apparently there is a cached CI VM with buck installed in the same directory as the project.
This has been fixed for a few weeks already but we still get this cache loaded some times.

This fixes the error
`undefined is not an object (evaluating 'this.refs[NATIVE_REF].setNativeProps')`.
@@ -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);
Copy link
Contributor

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.

@ide
Copy link
Contributor

ide commented Apr 5, 2016

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.

@janicduplessis
Copy link
Contributor

Fixed something similar for RefreshControl. The ref is null if the PullToRefreshViewAndroid gets unmounted during the onRefresh callback.

@thomdixon
Copy link
Contributor Author

@ide can we merge this, since you merged the iOS patch that basically does the same thing? Or would you like a revision? Thanks!

@ide
Copy link
Contributor

ide commented Apr 13, 2016

Taking another look rn

@ide
Copy link
Contributor

ide commented Apr 13, 2016

Thanks for the fix. We need support for asynchrony in React :/

@facebook-github-bot shipit

@facebook-github-bot
Copy link
Contributor

Thanks for importing. If you are an FB employee go to Phabricator to review.

@mkonicek mkonicek added Import Failed Import Started This pull request has been imported. This does not imply the PR has been approved. labels Apr 14, 2016
@bestander
Copy link
Contributor

@facebook-github-bot shipit

@facebook-github-bot
Copy link
Contributor

Thanks for importing. If you are an FB employee go to Phabricator to review.

@ghost ghost closed this in d586daa Apr 19, 2016
ptmt pushed a commit to ptmt/react-native that referenced this pull request May 9, 2016
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
zebulgar pushed a commit to nightingale/react-native that referenced this pull request Jun 18, 2016
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
samerce pushed a commit to iodine/react-native that referenced this pull request Aug 23, 2016
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 pull request was closed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed. Import Started This pull request has been imported. This does not imply the PR has been approved.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

7 participants