Skip to content

Invalid hook call. #6

Description

@cawfree

When nesting my application within the <KeyboardShift />, it fails to render.

There's a couple of reasons why this could be:

  1. The entire dependency stack for this library (including a duplicate version of React) is included. Many of these could be moved to devDependencies/peerDependencies, with an explicit statement that the library depends upon @react-navigation/elements.
  2. This line which depends on conditional hook execution.

I was able to resolve the issue locally by installing @react-navigation/elements to my root project and deleting the local node_modules directory installed at node_modules/\@fullstackcraft/.

The package.json could look something like:

{
  "name": "@fullstackcraft/react-native-keyboard-shift",
  "version": "1.1.4",
  "description": "A 2020s compatible keyboard avoiding view for Android and iOS that just works.",
  "main": "lib/index.js",
  "types": "lib/index.d.ts",
  "scripts": {
    "test": "jest --config jestconfig.json",
    "build": "tsc",
    "format": "prettier --write \"src/**/*.ts\" \"src/**/*.tsx\"",
    "lint": "tslint -p tsconfig.json",
    "prepare": "npm run build",
    "prepublishOnly": "npm test && npm run lint",
    "preversion": "npm run lint",
    "version": "npm run format && git add -A src",
    "postversion": "git push && git push --tags"
  },
  "dependencies": {
    "@react-native-community/hooks": "^2.6.0",
-   "@react-navigation/elements": "^1.1.2",
+   "@react-navigation/elements": "^1.1.2"
-    "react": ">= 17.0.2",
-    "react-native": ">=0.64.0"
  },
  "repository": {
    "type": "git",
    "url": "git+https://github.com/FullStackCraft/react-native-keyboard-shift.git"
  },
  "keywords": [
    "react",
    "native",
    "keyboard",
    "keyboardshift",
    "keyboard",
    "shift",
    "android",
    "ios"
  ],
  "author": "Chris Frewin",
  "license": "MIT",
  "bugs": {
    "url": "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/FullStackCraft/react-native-keyboard-shift/issues"
  },
  "homepage": "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/FullStackCraft/react-native-keyboard-shift#readme",
  "devDependencies": {
    "@types/jest": "^27.0.2",
    "@types/node": "^16.10.2",
    "@types/react": "^17.0.26",
    "@types/react-native": "^0.65.3",
    "jest": "^27.2.4",
    "prettier": "^2.4.1",
+   "react": ">= 17.0.2",
+   "react-native": ">=0.64.0",
    "ts-jest": "^27.0.5",
    "tslint": "^6.1.3",
    "tslint-config-prettier": "^1.18.0"
  },
  "files": [
    "lib/**/*"
  ]
}

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions