react-native-datetimepicker / datetimepicker

React Native date & time picker component for iOS, Android and Windows
MIT License
2.51k stars 409 forks source link

Invariant Violation: Tried to register two views with the same name RNDateTimePicker #414

Closed claudiozam closed 3 years ago

claudiozam commented 3 years ago

Bug report

Summary

Unable to start the app in ios after update the datetimepicker to ver. @react-native-community/datetimepicker@3.4.0.

[Thu Mar 18 2021 21:33:42.444]  ERROR    Invariant Violation: Tried to register two views with the same name RNDateTimePicker
[Thu Mar 18 2021 21:33:42.444]  ERROR    Invariant Violation: Module AppRegistry is not a registered callable module (calling runApplication)

Reproducible sample code

Steps to reproduce

  1. Update the lib to @react-native-community/datetimepicker@3.4.0
  2. run: yarn ios

Environment info

npx react-native info output:

System:
    OS: macOS 11.2.3
    CPU: (4) x64 Intel(R) Core(TM) i5-6360U CPU @ 2.00GHz
    Memory: 281.48 MB / 16.00 GB
    Shell: 5.8 - /bin/zsh
  Binaries:
    Node: 15.2.1 - /usr/local/bin/node
    Yarn: 1.22.10 - /usr/local/bin/yarn
    npm: 7.5.4 - /usr/local/bin/npm
    Watchman: Not Found
  Managers:
    CocoaPods: 1.10.0 - /usr/local/bin/pod
  SDKs:
    iOS SDK:
      Platforms: iOS 14.4, DriverKit 20.2, macOS 11.1, tvOS 14.3, watchOS 7.2
    Android SDK: Not Found
  IDEs:
    Android Studio: 4.1 AI-201.8743.12.41.6953283
    Xcode: 12.4/12D4e - /usr/bin/xcodebuild
  Languages:
    Java: 14.0.2 - /usr/bin/javac
    Python: 2.7.16 - /usr/bin/python
  npmPackages:
    @react-native-community/cli: Not Found
    react: 16.14.0 => 16.14.0 
    react-native: ^0.63.4 => 0.63.4 
    react-native-macos: Not Found
  npmGlobalPackages:
    *react-native*: Not Found
  "dependencies": {
    "@babel/core": "^7.12.10",
    "@fortawesome/fontawesome-svg-core": "^1.2.34",
    "@fortawesome/free-brands-svg-icons": "^5.15.2",
    "@fortawesome/pro-light-svg-icons": "^5.15.2",
    "@fortawesome/pro-regular-svg-icons": "^5.15.2",
    "@fortawesome/pro-solid-svg-icons": "^5.15.2",
    "@fortawesome/react-native-fontawesome": "^0.2.6",
    "@invertase/react-native-apple-authentication": "^2.1.1",
    "@react-native-clipboard/clipboard": "^1.6.0",
    "@react-native-community/art": "^1.2.0",
    "@react-native-community/async-storage": "^1.12.1",
    "@react-native-community/audio-toolkit": "^2.0.3",
    "@react-native-community/datetimepicker": "^3.4.0",
    "@react-native-community/google-signin": "^5.0.0",
    "@react-native-community/masked-view": "^0.1.10",
    "@react-native-community/slider": "^3.0.3",
    "@react-native-firebase/analytics": "7.3.1",
    "@react-native-firebase/app": "8.2.0",
    "@react-native-picker/picker": "^1.9.10",
    "@types/uuid": "7.0.4",
    "axios": "^0.21.1",
    "color": "^3.1.3",
    "formik": "^2.2.6",
    "fsevents": "2.2.1",
    "hermes-engine": "0.5.2-rc1",
    "immutability-helper": "^3.1.1",
    "link-preview-js": "^2.1.3",
    "lodash": "^4.17.20",
    "native-base": "^2.15.2",
    "pretty-bytes": "^5.5.0",
    "randomcolor": "^0.6.2",
    "react": "16.14.0",
    "react-native": "^0.63.4",
    "react-native-add-calendar-event": "^4.0.0",
    "react-native-base64": "^0.2.1",
    "react-native-calendars": "^1.1129.0",
    "react-native-config": "^1.4.1",
    "react-native-device-info": "^8.0.0",
    "react-native-document-picker": "^5.0.0",
    "react-native-fast-image": "^8.3.4",
    "react-native-fbsdk": "1.1.2",
    "react-native-ffmpeg": "^0.5.1",
    "react-native-file-viewer": "^2.1.4",
    "react-native-gesture-handler": "^1.9.0",
    "react-native-gifted-chat": "^0.16.3",
    "react-native-heic-converter": "^1.3.0",
    "react-native-hide-with-keyboard": "^1.2.1",
    "react-native-image-crop-picker": "^0.36.0",
    "react-native-image-zoom-viewer": "^3.0.1",
    "react-native-inappbrowser-reborn": "^3.5.1",
    "react-native-iphone-x-helper": "^1.3.1",
    "react-native-linear-gradient": "^2.5.6",
    "react-native-loading-spinner-overlay": "^2.0.0",
    "react-native-masked-text": "^1.13.0",
    "react-native-mime-types": "^2.3.0",
    "react-native-modal": "^11.6.1",
    "react-native-modal-datetime-picker": "^9.1.0",
    "react-native-notifications": "^3.4.2",
    "react-native-orientation-locker": "^1.2.0",
    "react-native-permissions": "^3.0.1",
    "react-native-progress": "^4.1.2",
    "react-native-push-notification-popup": "^1.6.0",
    "react-native-rate": "^1.2.4",
    "react-native-reanimated": "^1.13.2",
    "react-native-render-html": "^4.2.5",
    "react-native-safe-area-context": "^3.1.9",
    "react-native-screens": "^2.16.1",
    "react-native-share": "^5.1.0",
    "react-native-simple-dialogs": "^1.4.0",
    "react-native-simple-toast": "^1.1.3",
    "react-native-snap-carousel": "^3.9.1",
    "react-native-spinkit": "^1.5.1",
    "react-native-splash-screen": "^3.2.0",
    "react-native-svg": "^12.1.0",
    "react-native-swipe-gestures": "^1.0.5",
    "react-native-vector-icons": "^7.1.0",
    "react-native-version": "^4.0.0",
    "react-native-video": "^5.1.1",
    "react-native-webview": "^11.0.3",
    "react-navigation": "^4.4.3",
    "react-navigation-drawer": "^2.6.0",
    "react-navigation-stack": "^2.10.2",
    "react-redux": "7.2.2",
    "read-package-json": "^3.0.0",
    "redux": "^4.0.5",
    "redux-persist": "^6.0.0",
    "redux-thunk": "^2.3.0",
    "rn-fetch-blob": "^0.12.0",
    "rn-placeholder": "^3.0.3",
    "rollbar-react-native": "^0.9.1",
    "sanitize-filename": "^1.6.3",
    "striptags": "^3.1.1",
    "url": "^0.11.0",
    "yup": "^0.32.8"
  },
  "devDependencies": {
    "@babel/runtime": "7.12.5",
    "@react-native-community/eslint-config": "^1.1.0",
    "babel-jest": "25.5.1",
    "detox": "17.14.3",
    "eslint": "^6.8.0",
    "jest": "25.5.4",
    "metro-react-native-babel-preset": "^0.59.0",
    "properties-reader": "^1.0.0",
    "react-test-renderer": "16.14.0",
    "redux-devtools": "3.7.0"
  },
  "jest": {
    "preset": "react-native"
  }

datetimepicker version: 3.4.0

iOS 14.4

claudiozam commented 3 years ago

With version 3.0.9, no problem

vonovak commented 3 years ago

hello and thanks for reporting, given there is no runnable repro I cannot test this myself but I tend to believe that the culprit is in the fact that you're depending on both "@react-native-community/datetimepicker" and "react-native-modal-datetime-picker" which uses "@react-native-community/datetimepicker". Maybe having two different versions that you depend on causes the issue.

Hope this helps.

claudiozam commented 3 years ago

Thanks @vonovak

akashdeepsharma1991 commented 3 years ago

how did u solved it please help

claudiozam commented 3 years ago

@akashdeepsharma1991 I removed duplicated entries in yarn.lock (package.lock). But this idea is not working with 3.5.2. Problem 1: react-native-modal-datetime-picker, problem 2: native-base

akashdeepsharma1991 commented 3 years ago

Any update on this ... really frustrating issue.. Is there any specific version combination that need to be use.. I tried one from the example to working..

claudiozam commented 3 years ago

datetimepicker: 3.5.0 react-native-modal-datetime-picker: ^10.0.0

manojkumar402 commented 3 years ago

@claudiozam The above versions did not work on my m1 machine

claudiozam commented 3 years ago

@manojkumar402 try to add this to your package.json

"resolutions": { "@react-native-community/datetimepicker": "3.5.0" }

devWaleed commented 2 years ago

@manojkumar402 try to add this to your package.json

"resolutions": { "@react-native-community/datetimepicker": "3.5.0" }

This worked for me with version similar which was required by react-native-modal-datetime-picker

dafivius commented 2 years ago

Was fighting with it for 2 days. My version is "@react-native-community/datetimepicker": "3.2.0". Remove node_modules, delete package-lock.json and is just added ^ in your dependency => "@react-native-community/datetimepicker": "^3.2.0". Didn't need "resolutions" section in my case. Native base version is ^2.13.14

gurudewan commented 2 years ago

FYI: i faced this error cos i used yarn to add a package, while npm was already managing all my other packages

so there was a clash

fixed by deleting node_modules, deleting yarn.lock and then doing a fresh npm install

satyabrata45 commented 2 years ago

ERROR Error: Requiring module "node_modules/native-base/dist/src/index.js", which threw an exception: Invariant Violation: Tried to register two views with the same name RNDateTimePicker

bdiallo commented 2 years ago

I had the same problem too and the only temporary solution I could find was to add the smallest version with ^ (in my case "@react-native-community/datetimepicker": "^3.0.2",)

dmcgprod commented 2 years ago

my error - Requiring module "node_modules/react-native-weekly-calendar/node_modules/@react-native-community/datetimepicker/src/picker.ios.js", which threw an exception: Invariant Violation: Tried to register two views with the same name RNDateTimePicker

SOLVED just delete folder (second version) = node_modules/react-native-weekly-calendar/node_modules/@react-native-community/datetimepicker cause we have already one global

rajdeep74 commented 1 year ago

Same issue i was also facing .

Installing following version fixed the issue

"@react-native-community/datetimepicker": "^3.5.0",

ankit-navyug commented 1 year ago

I am facing the same issue @claudiozam on RN 0.66.4 version. Here is my dependencies

"dependencies": { "@bam.tech/react-native-image-resizer": "^3.0.4", "@native-html/table-plugin": "^2.1.4", "@native-html/transient-render-engine": "^11.2.3", "@react-native-async-storage/async-storage": "^1.17.11", "@react-native-community/cli": "^3.1.0", "@react-native-community/cli-platform-android": "^4.3.0", "@react-native-community/datetimepicker": "^6.7.1", "@react-native-community/netinfo": "^5.9.6", "@react-native-community/push-notification-ios": "^1.10.1", "@react-native-community/toolbar-android": "^0.2.1", "@react-native-firebase/app": "^16.4.6", "@react-native-firebase/messaging": "^16.4.6", "@react-native-picker/picker": "^2.4.4", "@react-native/normalize-color": "^2.0.0", "country-data": "0.0.31", "formik": "^2.1.4", "glob": "^7.1.6", "immer": "^5.3.6", "moment": "^2.24.0", "moment-timezone": "^0.5.41", "native-base": "^2.13.15", "object-to-formdata": "^3.0.9", "pluralize": "^8.0.0", "prop-types": "^15.7.2", "react": "17.0.2", "react-native": "^0.66.4", "react-native-autocomplete-input": "^5.0.0", "react-native-background-timer": "^2.4.1", "react-native-check-box": "^2.1.7", "react-native-collapsible": "^1.5.1", "react-native-copilot": "^2.4.7", "react-native-elements": "^1.2.7", "react-native-fs": "^2.16.6", "react-native-i18n": "^2.0.15", "react-native-image-crop-picker": "^0.32.2", "react-native-image-picker": "^2.3.1", "react-native-inappbrowser-reborn": "^3.4.0", "react-native-keyboard-aware-scroll-view": "^0.9.5", "react-native-localize": "^2.2.5", "react-native-markdown-display": "^6.1.6", "react-native-modal": "^11.5.6", "react-native-popup-menu": "^0.15.7", "react-native-push-notification": "^8.1.1", "react-native-render-html": "^4.2.3", "react-native-safe-area-context": "^4.3.3", "react-native-scroll-into-view": "^2.0.1", "react-native-simple-radio-button": "^2.7.4", "react-native-splash-screen": "^3.2.0", "react-native-status-bar-height": "^2.5.0", "react-native-svg": "^12.1.0", "react-native-table-component": "^1.2.1", "react-native-vector-icons": "^6.7.0", "react-native-webview": "11.23.1", "react-redux": "^7.1.3", "react-router-native": "^5.1.2", "redux": "^4.0.5", "redux-saga": "^1.1.3", "rn-fetch-blob": "^0.12.0", "styled-components": "^5.3.5", "victory-native": "^36.6.8", "yup": "^0.28.1" },

not able to resolve, can someone suggest solution?

claudiozam commented 1 year ago

Hi @ankit-navyug. This is the problem -> "native-base": "^2.13.15".

Try to use resolutions. For example:

"resolutions": { "@react-native-community/datetimepicker": "3.5.2" }

May the force be with you....