alexbrillant / react-native-deck-swiper

tinder like react-native deck swiper
ISC License
1.55k stars 462 forks source link

Warning: Invalid argument supplied to oneOf, expected an instance of array. #200

Open dengue8830 opened 5 years ago

dengue8830 commented 5 years ago

just copied the example swiper provided by the repo and it throws an Warning: Invalid argument supplied to oneOf, expected an instance of array. but the swiper works fine

my package.json

{
  "name": "taxitul",
  "version": "0.0.1",
  "private": true,
  "scripts": {
    "start": "node node_modules/react-native/local-cli/cli.js start",
    "android": "react-native run-android",
    "ios": "react-native run-ios --simulator='iPhone 6s Plus'",
    "test": "jest",
    "tsc": "tsc"
  },
  "dependencies": {
    "axios": "0.18.0",
    "formik": "1.3.2",
    "human-readable-ids": "1.0.4",
    "moment": "2.22.2",
    "native-base": "2.8.1",
    "react": "16.6.1",
    "react-native": "0.57.5",
    "react-native-animatable": "1.3.0",
    "react-native-audio-toolkit": "^1.0.6",
    "react-native-deck-swiper": "^1.5.26",
    "react-native-device-info": "0.24.3",
    "react-native-dropdownalert": "3.7.1",
    "react-native-exit-app": "1.0.0",
    "react-native-firebase": "5.1.1",
    "react-native-geocoding": "0.3.0",
    "react-native-loading-spinner-overlay": "1.0.1",
    "react-native-maps": "0.22.1",
    "react-native-mauron85-background-geolocation": "0.5.0-alpha.47",
    "react-native-permissions": "1.1.1",
    "react-native-side-menu": "^1.1.3",
    "react-router-native": "4.3.0",
    "unstated": "2.1.1",
    "validator": "10.9.0"
  },
  "devDependencies": {
    "@types/jest": "23.3.9",
    "@types/node": "10.12.9",
    "@types/react": "16.7.6",
    "@types/react-native": "0.57.11",
    "@types/react-native-permissions": "1.1.1",
    "@types/react-router-native": "4.2.3",
    "@types/react-test-renderer": "16.0.3",
    "@types/validator": "9.4.3",
    "babel-jest": "23.6.0",
    "jest": "23.6.0",
    "metro-react-native-babel-preset": "0.49.2",
    "react-test-renderer": "16.6.1",
    "ts-jest": "23.10.4",
    "typescript": "3.1.6"
  },
  "jest": {
    "preset": "react-native",
    "transform": {
      "^.+\\.js$": "<rootDir>/node_modules/react-native/jest/preprocessor.js",
      ".+\\.tsx?$": "ts-jest"
    },
    "testRegex": "(/__tests__/.*|(\\.|/)(test|spec))\\.(jsx?|tsx?)$",
    "moduleFileExtensions": [
      "ts",
      "tsx",
      "js"
    ],
    "modulePaths": [
      "<rootDir>"
    ]
  }
}
webraptor commented 5 years ago

This has been fixed in 1.6.2

@alexbrillant looks like the latest version isn't pushed to npm. @dengue8830 you can use the master branch latest commit in the meantime.

dengue8830 commented 5 years ago

thanks, i will reference the github master branch in the package.json to get the lastest version

igorbrandao commented 5 years ago

I was having this issue as well and I hate being thrown warnings at, so I went on making a fork of latest master and using that in my project just swapped this warning with another: can't call setstate (or forceUpdate) on an unmounted component because of line 122 of Swiper.js

I removed that one line and no more warnings showed up (I don't need it anyway because my app is locked on portrait mode and it was added in a PR that fixed device rotation), but when I swiped all of the cards, it immediately crashes the app even before onSwipedAll gets called as the swiper tries to render a card out of cards bounds, calling renderCard with empty data . 😞

The solution I found to all of this and am currently using was to downgrade to 1.5.25 version as it doesn't have any of oneOf... and can't call setState... warnings and has consistent behaviour for renderCard/onSwipeAll. Don't bother versions 1.5.23 and 1.5.24 as they are broken. In these, just as your app loads you get TypeError: TypeError: TypeError: TypeError: this.calculateCardIndexes is not a function. (In 'this.calculateCardIndexes(props.cardIndex, props.cards)', 'this.calculateCardIndexes' is undefined).

Hope it helps someone!

georgeMorales commented 5 years ago

Hello, I had version 1.5.22 and I did not get that annoying warning but updated to see if I could fix the problem of the edge in overlayLabels in android that when you slide the card the edge does a strange thing #140 and this warning appears in the latest version, and the problem of the edges is not fixed, but if I go back to my initial version, 1.5.22, now that warning continues to appear!

igorbrandao commented 5 years ago

@JorgeMoralesLopez you have to delete both node-modules and package-lock | yarn-lock files in order to rollback to a previous version after installing a more recent one :)

webraptor commented 5 years ago

@JorgeMoralesLopez the issue in #140 is due to RN not the library itself. Looks like @alexbrillant didn't push the latest changes to NPM, so try using the latest master release instead until last version is published (1.6.2).

within package.json:

"react-native-deck-swiper": "alexbrillant/react-native-deck-swiper#37974103aa18e18ea65764100b4116b3d4bbaf2e"
georgeMorales commented 5 years ago

Thanks igorbrandao, webraptor, I have updated to 1.6.2 and I get other errors as igorbrando described in his post as: Warning: Can't call forceUpdate on a component that is not yet mounted. This is a no-op, but it might indicate a bug in your application. Instead, assign to this.state directly or define a state = {}; class property with the desired state in the Swiper component. and... ExceptionsManager.js:71 Warning: Encountered two children with the same key, 0. Keys should be unique so that components maintain their identity across updates. Non-unique keys may cause children to be duplicated and/or omitted — the behavior is unsupported and could change in a future version.

The issue is that yesterday everything worked fine with version 1.5.22, but now if I go backwards, deleting the package json lock I still get the oneOf warning although it seems that it is better than the one that appears now ...

webraptor commented 5 years ago

try clearing bundler cache, build cache etc..., clear watchman, clear yarn, remove node_modules and then reinstall and rebuild.

You can also try going a bit back in the commits history: https://github.com/alexbrillant/react-native-deck-swiper/commits/master . I see that there were a lot of commits since we last contributed.

igorbrandao commented 5 years ago

@webraptor latest master (1.6.2) still has the can't call forceUpdate warning.

@JorgeMoralesLopez the latest version that has no warnings is 1.5.25, and 1.5.22 also works fine as well. If you are still encountering these warnings it is because of your local setup.

webraptor commented 5 years ago

@igorbrandao That's why I recommended going back with some of the commits, as some may have introduced issues.

I don't recall experiencing the forceUpdate issue on our latest version, prior to our PR on the 28th of November, 2018.

@JorgeMoralesLopez try with "luminos-software/react-native-deck-swiper#36807af7b85e05c316a95809541d689df12777f2" which is when we bumped the version to 1.6.2 . I don't know at this point what other changes have been made since then as we were off for the holidays.

georgeMorales commented 5 years ago

I deleted node modules and package json lock I installed the version @webraptor "luminos-software / react-native-deck-swiper # 36807af7b85e05c316a95809541d689df12777f2" and the problem of oneOf disappears but the problem appears of forceUpdate and Encountered two children with the same key, 0 ... and it seems that the cards have a strange behavior, however, if infinite happens to false only the problem of forceUpdate appears. I have two components in which I use swiper, although I have been developing it for a few months and I only encountered the problem of forceUpdate when I wanted to paginate with firebase, but if I did not implement that function the warning did not appear and I thought that the function was not well done and I left it for later ... is it possible that what Encountered two children is because I use two swiper? although they are two different components ... I am quite involved with this since yesterday everything had worked out very well. Thank you!

javiio commented 5 years ago

When are you planning to release v1.6.2 (or a newer version) to npm?

I am also experiencing the 'forceUpdate' warning with v1.6.2, also now the cardIndex is not automatically updated after every swipe but I need to manually update it (using internal state), the problem with this is that the next card shows up with no animation.