React-native-swiper: crash on android

Created on 16 Aug 2017  路  9Comments  路  Source: leecade/react-native-swiper

Which OS ?

android

Version

Which versions are you using:

  • react-native-swiper v1.5.10
  • react-native v0.47.1

Expected behaviour

no crash!

Actual behaviour

the app crashes due to this line:

updateIndex = (offset, dir, cb) => { const state = this.state let index = state.index const diff = offset[dir] - this.internals.offset[dir] const step = dir === 'x' ? state.width : state.height let loopJump = false ...
because this.internals.offset is undefined

Need answer from author no reproduction

Most helpful comment

I found the issue. In the initState method, to the end, you need to change:
this.internals = {
...this.internals,
isScrolling: false
};
to
this.internals = {
...initState,
isScrolling: false
};
It looks like the internals is initiated there and there's no other reference of it.
Whoever need to give it a ride can test the fork here:
https://github.com/valinaga/react-native-swiper
Hope it helped.

All 9 comments

moreover swiping the image cause an infinite and fast loop

And ...
I do not have this bug in my case and in any examples. Can you give us an example in which we can reproduce the bug ?
Thanks !

Same situation. Please help.

@slicejunk did you found the soluiton for this?

@slicejunk @hbk671104
Again, I do not have this bug. Check again with the last version, 1.5.11 and if you have a bug, fork the project and reproduce it one example. I cannot help you if you don't do that

same here.
I'm on 1.5.12 and the issue is present.
The autoplay is true and autoplayTimeout is 4.
Here is the code. The banner is a custom component made of View and Image, nothing fancy.
<Swiper autoplay autoplayTimeout={4} height={height} style={styles.wrapper} activeDotColor={'red'} > {list.map((item, index) => <Banner key={index} item={item} />)} </Swiper>
The height is calculated at render time based on the width of the device.

@arribbar , @slicejunk it looks like it's because of the autoplay. Once it get to the end of the slides the issue appears. hope this help.

I found the issue. In the initState method, to the end, you need to change:
this.internals = {
...this.internals,
isScrolling: false
};
to
this.internals = {
...initState,
isScrolling: false
};
It looks like the internals is initiated there and there's no other reference of it.
Whoever need to give it a ride can test the fork here:
https://github.com/valinaga/react-native-swiper
Hope it helped.

swiper codes:

<Swiper
    style={{ backgroundColor: "#ffffff" }}
    height={px2dp(154)}
    index={0}
    bounces={false}
    autoplay={true}
    autoplayTimeout={3}
    showsButtons={false}
    paginationStyle={{ bottom: 0 }}
    dotStyle={{ backgroundColor: '#dedede', width: px2dp(10), height: px2dp(2) }}
    activeDotStyle={{ backgroundColor: '#00bc71', width: px2dp(10), height: px2dp(2) }}>
    {renderSwipeView()}
</Swiper>

and swiper codes are in the FlatList component.Then I have the same question , need help please.

Same issue here, when i build gradlew assembleRelease and i test with my android phone the application crash, i'm using your suggestion brother @valinaga.

Pls help me

Was this page helpful?
0 / 5 - 0 ratings

Related issues

wrannaman picture wrannaman  路  3Comments

chetanparakh picture chetanparakh  路  3Comments

AndrewSouthpaw picture AndrewSouthpaw  路  3Comments

hadrienbbt picture hadrienbbt  路  3Comments

nicolabortignon picture nicolabortignon  路  3Comments