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

[flow-strict] Flow strict ScrollResponder #22181

Closed
wants to merge 6 commits into from

Conversation

saitoxu
Copy link
Contributor

@saitoxu saitoxu commented Nov 6, 2018

Related to #22100

Enhance Flow types for Libraries/Components/ScrollResponder.js

Test Plan:

  • npm run prettier
  • npm run lint
  • npm run flow
  • npm run flow-check-ios
  • npm run test

Changelog:

[GENERAL] [ENHANCEMENT] [ScrollResponder.js] - Flow types

@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 Nov 6, 2018
@pull-bot
Copy link

pull-bot commented Nov 6, 2018

Warnings
⚠️

📋 Release Notes - This PR appears to be missing Release Notes.

Generated by 🚫 dangerJS

@@ -113,7 +114,16 @@ type State = {
observedScrollSinceBecomingResponder: boolean,
becameResponderWhileAnimating: boolean,
};
type Event = Object;
type Event = $ReadOnly<{|
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is SyntheticEvent from CoreEventTypes helpful here?

Also, are we sure this shouldn't be ScrollEvent from CoreEventTypes? Where do you see that this event contains touches?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In response to your review, I changed PR a lot.

I found that the event defined by the existing flow type is getting passed in the arguments of all the functions defined in ScrollResponder, so we don't need to use SysntheticEvent here.

Copy link
Contributor

@RSNara RSNara left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good! 🤔

@@ -584,8 +588,8 @@ const ScrollResponderMixin = {
this.preventNegativeScrollOffset = false;
},

scrollResponderTextInputFocusError: function(e: Event) {
console.error('Error measuring text field: ', e);
scrollResponderTextInputFocusError: function(msg: string) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Was this function always being called with a string?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, the function is finally passed to UIManager.measureLayout as error callback.
In Java, the error callback argument is string, and in Objective-C, the callback is never called.

ref:

Copy link
Contributor

@facebook-github-bot facebook-github-bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@RSNara has imported this pull request. If you are a Facebook employee, you can view this diff on Phabricator.

@RSNara RSNara changed the title Flow strict ScrollResponder [flow-strict] Flow strict ScrollResponder Nov 12, 2018
@react-native-bot
Copy link
Collaborator

@saitoxu merged commit fb4825a into facebook:master.

@facebook facebook locked as resolved and limited conversation to collaborators Nov 21, 2018
@react-native-bot react-native-bot added the Merged This PR has been merged. label Nov 21, 2018
@saitoxu saitoxu deleted the flow_type_scroll_responder branch December 10, 2018 23:10
t-nanava pushed a commit to microsoft/react-native-macos that referenced this pull request Jun 17, 2019
Summary:
Related to facebook#22100

Enhance Flow types for Libraries/Components/ScrollResponder.js
Pull Request resolved: facebook#22181

Reviewed By: TheSavior

Differential Revision: D13032699

Pulled By: RSNara

fbshipit-source-id: ca0ce178a96008a71016d033ee1154ad807d6599
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed. Flow Merged This PR has been merged.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants