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

Manually bind PickerAndroid instance methods #9789

Closed
wants to merge 5 commits into from

Conversation

dzautner
Copy link
Contributor

@dzautner dzautner commented Sep 7, 2016

In the current version of react-native, the Picker component would some times fail on Android due undefined context (this === undefined) in the methods that are defined using the experimental class property syntax.

As this is experimental syntax which seems to be unreliable in its current form and usage, I suggest to manually bind these methods in the component's constructor.

Instead of using es7 class property syntax, manually bind the methods in the component's constructor.

The class property syntax is still experimental and seems to fail randomly where `this` ends up bound to `undefined`.
@ghost
Copy link

ghost commented Sep 7, 2016

By analyzing the blame information on this pull request, we identified @spicyj and @mkonicek to be potential reviewers.

@ghost
Copy link

ghost commented Sep 7, 2016

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!

@ghost ghost 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 Sep 7, 2016
@ghost
Copy link

ghost commented Sep 7, 2016

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

@ghost
Copy link

ghost commented Sep 8, 2016

@dzautner updated the pull request - view changes

@ghost ghost 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 Sep 8, 2016
@ghost
Copy link

ghost commented Sep 8, 2016

@dzautner updated the pull request - view changes

@ghost ghost 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 Sep 8, 2016
@mkonicek
Copy link
Contributor

mkonicek commented Sep 8, 2016

As this is experimental syntax which seems to be unreliable in its current form and usage, I suggest to manually bind these methods in the component's constructor.

We're using this syntax a lot and it should be reliable thanks to Babel. It looks like the code is equivalent actually. Can you consistently reproduce the bug with this being undefined? When does it happen? Does the bug go away with your change?

@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 Sep 8, 2016
@dzautner
Copy link
Contributor Author

dzautner commented Sep 9, 2016

@mkonicek, sorry for not providing enough information.

Yes, we can consistently reproduce the issue with this specific component. We actually use this exact code to resolve the issue temporarily until it is resolved upstream.

@ghost ghost 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 Sep 9, 2016
@ghost
Copy link

ghost commented Sep 9, 2016

@dzautner updated the pull request - view changes

@ghost ghost 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 Sep 9, 2016
@ghost
Copy link

ghost commented Sep 9, 2016

@dzautner updated the pull request - view changes

@ghost ghost 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 Sep 9, 2016
@sophiebits
Copy link
Contributor

Can you please determine why the current code is breaking?

@dzautner
Copy link
Contributor Author

I'll try to run some tests and narrow it down to the exact cause of the issue.

@dzautner
Copy link
Contributor Author

dzautner commented Sep 12, 2016

@spicyj:

I narrowed the issue down to an issue with babel the is already acknowledged. When using babel with passPerPreset the class property syntax will not be bound to the wrong context.

babel/babel#4230
babel/babel#4337

@ghost ghost 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 Sep 12, 2016
@sophiebits
Copy link
Contributor

Yeah, that's unfortunate. If you have transform-class-properties in the plugins section then it will work.

@dzautner
Copy link
Contributor Author

👍 thanks!

@dzautner dzautner closed this Sep 14, 2016
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.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants