React-native-swiper: undefined is not an object (evaluating'_this.internals.offset[dir]')

Created on 22 Sep 2017  ·  37Comments  ·  Source: leecade/react-native-swiper

Which OS ?

Android

Version

Which versions are you using:

  • react-native-swiper v1.5.10?
  • react-native v0.46.4

Describe

I'm developing a shopping website. On the goods description page,I used swiper. Goods description page can jump to the shopping cart page (navigator.push) and shopping cart page can jump to the goods description page too (infinite stack). The problem is that when there are more than one swiper in the stack, the code prompts "undefined is not an object" in 'updateIndex' function.

problem

Android no reproduction 🐛bug

Most helpful comment

I solve this problem.
node_modules/react-native-swiper/src/index.js 398 line add
if(offset === undefined || this.internals.offset === undefined){ return; }

All 37 comments

Sup. I had a very similar problem, but my swiper just swiped correctly, but I had an error same as yours. If everything works ok, but the problem is just an error you can use not so gentle way to null it. In the "updateIndex" method wrap the content in if(this.internals.offset){##content}. This validator helped me get rid off this error. In my case it worked on 2 android devices. On ios I have a problem with scrolling to index, so right now I'm not sure about it.

Can you try with the latest version, 1.5.13 ?
If it does it again, can you fork this project and reproduce the bug in the examples ?

+1, Any news on this?

RN 48.4
react-native-swiper 1.5.9

I meet the same question

I meet the same question :( please

+1
react-native-swiper 1.5.13
RN 49.3

reverting back to version 1.5.8, it's working fine.

How can i know the vertion of my swiper?
how to reverting back to version 1.5.8 ?

+1
react-native-swiper 1.5.8
RN 48.0

Crash : com.facebook.react.common.JavascriptException: undefined is not an object (evaluating 'n.internals.offset[e]'), stack:,共5次

In my case,
RN 0.49
react-native-swiper 1.5.13
In Android, problem caused by 'onLayout' event fired after this.swiper.scrollBy(...)..
But react-native-swiper initialized in onLayout event phase..
So.. I solved this issue.. by..

  1. Add isSwiperLoaded state.. like this.state={..., isSwiperLoaded: false};
  2. attach onLayout listener like
  3. call this.swiper.scrollBy(...) with some delay in componentDidUpdate like...
    componentDidUpdate(prevProps, prevState) {
    ..
    if (!this.state.isSwiperLoading) {
    setTimeout(() => {
    this.swiper.scrollBy(...);
    }, 200);

That's all.
I hope someone helped.

can anybody help ?

Having the same problem here

@KamranKhankhail it works fine for me . thx

when i re-install 1.5.8 , the error gone,but swiper does not work. So i re-install 1.5.9, everything goes fine. yarn add [email protected]

@arribbar I meet the same question

I solve this problem.
node_modules/react-native-swiper/src/index.js 398 line add
if(offset === undefined || this.internals.offset === undefined){ return; }

I meet the same question
"react-native-swiper": "^1.5.13",
"react-native": "0.51.0"

But after rebuild my project, it be resovle!!

@yoyo0427 add this code, not crash, but can not swip auto. see thishttps://github.com/leecade/react-native-swiper/issues/521 there have another way to solve in comments

I solve this problem.
"react-native-swiper": "https://github.com/Tennen/react-native-swiper.git",
loop={this.state.dataList.length>1}

+1

+1 for slow devices - navigating out of view - need to protect against unmounting or it will crash the app

Same here. My app is in production, crashes for a lot of users because of this issue :(

facing same crash on android with version 1.5.13

Same question.

+1

Is it safe to say that this repository is dead or have someone been successful in contacting @leecade ?

+1

I have the same problem on 1.5.13
com.facebook.react.common.JavascriptException: undefined is not an object (evaluating 'n.internals.offset[e]')
can anyone help me?

@2linziyi2

My plugin is currently pointing to this forked git repo that has the fix to this issue. So far I'm no longer getting this error. Hope this helps!

我也有同样的问题,已经哭晕了

Same

@zhaoqigang Your repo working with me. Thank you.

I solve this problem.
node_modules/react-native-swiper/src/index.js 398 line add
if(offset === undefined || this.internals.offset === undefined){ return; }

Please implement this in the repo

@leecade @arribbar can any of you guys do something about this issue please...?

I have same this issue. Please help me to fix it. Thanks Admin

I have same this issue,it make me crazzy。

+1 for me would be nice to have a fix please

I have same issue with react native 0.58.6 !!!

Was this page helpful?
0 / 5 - 0 ratings

Related issues

hadrienbbt picture hadrienbbt  ·  3Comments

gwhite-dayspring picture gwhite-dayspring  ·  3Comments

agzuniverse picture agzuniverse  ·  3Comments

itinance picture itinance  ·  3Comments

nicolabortignon picture nicolabortignon  ·  3Comments