React-native-keyboard-aware-scroll-view: Flow erros

Created on 17 Oct 2018  ยท  11Comments  ยท  Source: APSL/react-native-keyboard-aware-scroll-view

Hi, since I updated to the latest version I am having lots of flow errors considering this lib :

hope this issue wasn't already known.

[flow] Cannot create `KeyboardAwareScrollView` element because a callable signature is missing in props [1] but exists in function type [2]. (References: [1] [2])
[flow] Cannot instantiate `React.Element` because in type argument `ElementType`: Either inexact statics of `<<anonymous class>>` [1] is incompatible with exact `React.Element` [2] in the return value. Or statics of `<<anonymous class>>` [1] is incompatible with `React.Portal` [3] in the return value. Or property `@@iterator` is missing in statics of `<<anonymous class>>` [1] but exists in `$Iterable` [4] in the return value. Or function [5] is incompatible with statics of `React.Component` [6]. (References: [1] [2] [3] [4] [5] [6])
[flow] all branches are incompatible: Either inexact statics of `<<anonymous class>>` [1] is incompatible with exact `React.Element` [2]. Or statics of `<<anonymous class>>` [1] is incompatible with `React.Portal` [3]. Or property `@@iterator` is missing in statics of `<<anonymous class>>` [1] but exists in `$Iterable` [4]. (References: [1] [2] [3] [4])

I am using :

    "debounce": "^1.1.0",
    "lodash": "^4.17.10",
    "lottie-react-native": "^2.5.8",
    "moment": "^2.20.1",
    "moment-timezone": "^0.5.14",
    "react": "16.3.1",
    "react-native": "0.55.4",
    "react-native-keyboard-aware-scroll-view": "^0.7.3",
    "react-navigation": "^2.17.0",
    ....

For the moment I avoided the problem with ignoring it like explained here :

https://github.com/APSL/react-native-keyboard-aware-scroll-view/issues/117

Thanks a lot.

Most helpful comment

If you ignore the entire module in .flowconfig you'll get different warnings.
But so far I've had luck with ignoring on the one file, so add this be ignored to .flowconfig
/node_modules/react-native-keyboard-aware-scroll-view/lib/KeyboardAwareHOC.js

All 11 comments

Can you send a PR with the Flow fixes? Thanks.

I would love to though adding an ignore isn't a valid correction and I don't know how to make a better way for the moment ;)

@MounirDhahri it is what I already did it was in the link and in my comment ;)
Though it "works" I get another warning

I have the flow issue thing in my roadmap for this week. Sorry guys, I'm running too much OSS stuff myself alone atm.

Just FYI, we're experiencing the flow issues and the fix is almost 50% already done, but priorities come first.

@alvaromb thanks for the update on this case that's nice to hear :) ๐Ÿ‘

Working on this right now https://github.com/APSL/react-native-keyboard-aware-scroll-view/tree/flow-issues

Please test this branch with flow WIP

@alvaromb That branch is a lot better (3 errors vs 30) for my project. At the moment I just added // $FlowFixMe comments to those three lines to clear the rest of the errors out and everything's working.

Error โ”ˆโ”ˆโ”ˆโ”ˆโ”ˆโ”ˆโ”ˆโ”ˆโ”ˆโ”ˆโ”ˆโ”ˆโ”ˆโ”ˆโ”ˆโ”ˆโ”ˆโ”ˆโ”ˆโ”ˆโ”ˆโ”ˆโ”ˆโ”ˆโ”ˆโ”ˆโ”ˆโ”ˆโ”ˆโ”ˆ node_modules/react-native-keyboard-aware-scroll-view/lib/KeyboardAwareHOC.js:385:49

Cannot get TextInput.State because property State is missing in statics of InternalTextInputType [1].

     node_modules/react-native-keyboard-aware-scroll-view/lib/KeyboardAwareHOC.js
      382โ”‚           keyboardSpace -= _KAM_DEFAULT_TAB_BAR_HEIGHT
      383โ”‚         }
      384โ”‚         this.setState({ keyboardSpace })
      385โ”‚         const currentlyFocusedField = TextInput.State.currentlyFocusedField()
      386โ”‚         const responder = this.getScrollResponder()
      387โ”‚         if (!currentlyFocusedField || !responder) {
      388โ”‚           return

     node_modules/react-native/Libraries/Components/TextInput/TextInput.js
 [1] 1205โ”‚ class InternalTextInputType extends ReactNative.NativeComponent<Props> {
Error โ”ˆโ”ˆโ”ˆโ”ˆโ”ˆโ”ˆโ”ˆโ”ˆโ”ˆโ”ˆโ”ˆโ”ˆโ”ˆโ”ˆโ”ˆโ”ˆโ”ˆโ”ˆโ”ˆโ”ˆโ”ˆโ”ˆโ”ˆโ”ˆโ”ˆโ”ˆโ”ˆโ”ˆโ”ˆโ”ˆ node_modules/react-native-keyboard-aware-scroll-view/lib/KeyboardAwareHOC.js:477:11

Cannot call this.scrollToFocusedInput with reactNode bound to reactNode because number [1] is incompatible with object
type [2].

     node_modules/react-native-keyboard-aware-scroll-view/lib/KeyboardAwareHOC.js
     474โ”‚       const reactNode = ReactNative.findNodeHandle(nodeID)
     475โ”‚       if (reactNode) {
     476โ”‚         this.scrollToFocusedInput(
     477โ”‚           reactNode,
     478โ”‚           extra + this.props.extraScrollHeight,
     479โ”‚           keyboardOpeningTime !== undefined
     480โ”‚             ? keyboardOpeningTime

     node_modules/react-native-keyboard-aware-scroll-view/lib/KeyboardAwareInterface.js
 [2]   9โ”‚     reactNode: Object,

     node_modules/react-native/Libraries/Renderer/shims/ReactNativeTypes.js
 [1] 133โ”‚   findNodeHandle(componentOrHandle: any): ?number,

Error โ”ˆโ”ˆโ”ˆโ”ˆโ”ˆโ”ˆโ”ˆโ”ˆโ”ˆโ”ˆโ”ˆโ”ˆโ”ˆโ”ˆโ”ˆโ”ˆโ”ˆโ”ˆโ”ˆโ”ˆโ”ˆโ”ˆโ”ˆโ”ˆโ”ˆโ”ˆโ”ˆโ”ˆโ”ˆโ”ˆ node_modules/react-native-keyboard-aware-scroll-view/lib/KeyboardAwareHOC.js:500:47

Cannot get TextInput.State because property State is missing in statics of InternalTextInputType [1].

     node_modules/react-native-keyboard-aware-scroll-view/lib/KeyboardAwareHOC.js
      497โ”‚     }
      498โ”‚
      499โ”‚     update = () => {
      500โ”‚       const currentlyFocusedField = TextInput.State.currentlyFocusedField()
      501โ”‚       const responder = this.getScrollResponder()
      502โ”‚       if (!currentlyFocusedField || !responder) {
      503โ”‚         return

     node_modules/react-native/Libraries/Components/TextInput/TextInput.js
 [1] 1205โ”‚ class InternalTextInputType extends ReactNative.NativeComponent<Props> {

If you ignore the entire module in .flowconfig you'll get different warnings.
But so far I've had luck with ignoring on the one file, so add this be ignored to .flowconfig
/node_modules/react-native-keyboard-aware-scroll-view/lib/KeyboardAwareHOC.js

As a workaround while this is still open, I used a slightly different approach to the [ignore] because that will give cannot resolve module errors when linting with flow. Instead I used [untyped] in .flowconfig:

[untyped]
; https://github.com/APSL/react-native-keyboard-aware-scroll-view/issues/315
<PROJECT_ROOT>/node_modules/react-native-keyboard-aware-scroll-view/lib/KeyboardAwareHOC.js

I've this error
error node_modules/react-native-keyboard-aware-scroll-view/lib/KeyboardAwareHOC.js: # could not be cloned.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

SunilPandey- picture SunilPandey-  ยท  4Comments

diegorodriguesvieira picture diegorodriguesvieira  ยท  4Comments

MyGuySi picture MyGuySi  ยท  3Comments

snksergio picture snksergio  ยท  3Comments

RBrNx picture RBrNx  ยท  4Comments