react-native-gifted-chat: Latest React Native 0.62.0: Type Errror: Super expression must either be null or a function

Issue Description

When upgrading to the latest version of RN 0.62.0 importing the package leads to Type Errror: Super expression must either be null or a function

Steps to Reproduce / Code Snippets

  1. Upgrade RN to 0.62.0.
  2. import { GiftedChat } from 'react-native-gifted-chat';
  3. Runtime error: Type Errror: Super expression must either be null or a function

Expected Results

Gifted Chat to load normally

Additional Information

Seems to spawn from GiftedChat.js line 3

  • Nodejs version: 12.16.1
  • React version: 16.11.0
  • React Native version: 0.62.0
  • react-native-gifted-chat version: 0.13.0
  • Platform(s) (iOS, Android, or both?): only tested on Android
  • TypeScript version: 3.8.3

About this issue

  • Original URL
  • State: closed
  • Created 4 years ago
  • Reactions: 21
  • Comments: 34 (1 by maintainers)

Most upvoted comments

I hacked together a fork w/ the new action-sheet using the currently released version here. Use it with yarn add https://github.com/StagasaurusRex/react-native-gifted-chat.git#upgrade-action-sheet or w/e the equivalent npm command is.

Based on https://github.com/StagasaurusRex/react-native-gifted-chat/commit/58ae0c8969d4e472538ed7abcecbb4ce81114f5f, I forced using the new version of action sheet lib which fixes the issue.

  1. Add this to the top level of the package.json
  "resolutions": {
    "@expo/react-native-action-sheet": "^3.6.0"
  }
  1. run yarn again

  2. The error should be gone ~

The package is updated now 🎉

Admin, Please update the expo/react-native-action-sheet/issues package to 3.6.0 in the gifted chat

With the library is everything ok. Cache was making problems in my case.

Make sure: 1.) You remove node_modules directory 2.) npm cache clean --force 3.) Delete package-lock.json and yarn-lock.json 4.) npm install 5.) If you are using expo run expo with command: expo r -c

@yogeverez I’ve just tried this but its showing the same error. May be it is just because I’m using NPM insted of Yarn as I’m working on Windows OS and Yarn is not suitable for Windows. I’ve tried all available solutions even changed the react-native-action-sheet version in both node module’s package.json file and as well as in my project’s package-lock.json. Nothing worked

@imAunAbbas, I don’t think it is related to ‘Yarn’ or OS. did you try to delete your package-lock.json file and node_modules folder before running npm install? Also, replace the react-native-gifted-chat dependency in you project package.json file with "react-native-gifted-chat": "https://github.com/StagasaurusRex/react-native-gifted-chat.git#upgrade-action-sheet". Then, try running npm install again

Based on StagasaurusRex@58ae0c8, I forced using the new version of action sheet lib which fixes the issue.

1. Add this to the top level of the `package.json`
  "resolutions": {
    "@expo/react-native-action-sheet": "^3.6.0"
  }
1. run `yarn` again

2. The error should be gone ~

Yeah. it’s work for me. Thank you

If you are using npm instead of yarn as your package manager, You need run npx npm-force-resolutions and then run npm install. Also, add it as a preinstall script.

 "scripts": {
    "android": "react-native run-android",
    "ios": "react-native run-ios",
    "start": "react-native start",
    "preinstall": "npx npm-force-resolutions"
  },
  "resolutions": {
    "@expo/react-native-action-sheet": "3.6.0"
  },

@FaridSafi mind updating the package

@imAunAbbas the easiest solution to workaround this issue until the relevant waiting Pull Request will be accepted, is to replace the react-native-gifted-chat dependency with the fork of @StagasaurusRex. Just remove the module from your project and run yarn add https://github.com/StagasaurusRex/react-native-gifted-chat.git#upgrade-action-sheet

My fork bypasses the build process and isn’t appropriate to merge. PR #1712 would be better.