APSL / react-native-keyboard-aware-scroll-view

A ScrollView component that handles keyboard appearance and automatically scrolls to focused TextInput.
MIT License
5.24k stars 643 forks source link

'KeyboardAwareScrollView' cannot be used as a JSX component. #533

Open ricohumme opened 2 years ago

ricohumme commented 2 years ago

Hi,

This error pops up when used and I haven't seen this error come through here. I'm using expo and typescript in my project. Has anyone encountered this issue and knowing how to resolve this? The full error is as follows:

'KeyboardAwareScrollView' cannot be used as a JSX component.
  Its instance type 'KeyboardAwareScrollView' is not a valid JSX element.
    The types returned by 'render()' are incompatible between these types.
      Type 'React.ReactNode' is not assignable to type 'import("....../node_modules/@types/react-native/node_modules/@types/react/index").ReactNode'.ts(2786)

The versions of packages I am using are the following:

react@17.0.1
react-native@0.64.3
typescript@4.3.5
@types/react@17.0.44
@types/react-native@0.64.24
expo@44.0.6
react-native-keyboard-aware-scroll-view@0.9.5

Hoping I'm not alone in this. Thank you in advance!

ricohumme commented 2 years ago

Could be related to https://github.com/DefinitelyTyped/DefinitelyTyped/issues/59765#issuecomment-1092891129 however my version is higher and I still have these lines

ricohumme commented 2 years ago

So adding

"resolutions": {
    "@types/react": "^17.0.41"
  },

resolves the issue. Hope it helps anyone in the same need :)

theafolayan commented 2 years ago

Thanks @ricohumme Solved the errors for me too!

mmsmadi commented 1 year ago

add this to your package.json, and make sure the version of "@types/react-native" is same as your react-native and "@types/react" is same as react in "dependencies".

"resolutions": {
    "@types/react-native": "^0.66.3",
    "@types/react": "17.0.2"
  }
diyordeveloper commented 1 year ago

fuck !

diyordeveloper commented 1 year ago

what the fuck ?

theafolayan commented 1 year ago

Hi, the issue seems to be a types issue and the comment above yours asking to install the types, seemed to fix the issue for me.

As an extra step, you may want to clear your node modules and rerun tsc Oluwaseun Raphael Oluwaseun

On Mon, Dec 19, 2022, 12:32 PM diyorbekdeveloper8850 < @.***> wrote:

fuck !

— Reply to this email directly, view it on GitHub https://github.com/APSL/react-native-keyboard-aware-scroll-view/issues/533#issuecomment-1357502467, or unsubscribe https://github.com/notifications/unsubscribe-auth/AKRIOXUUHX7YJ5UZLM3XM3LWOBBTVANCNFSM5TKKUYTA . You are receiving this because you commented.Message ID: @.*** .com>