react-native-swiper icon indicating copy to clipboard operation
react-native-swiper copied to clipboard

After the latest commit, all my swipers appear blank.

Open innerexception opened this issue 9 years ago • 41 comments

Not ideal.

innerexception avatar Aug 09 '17 19:08 innerexception

Which platform?

mrdezzods avatar Aug 09 '17 19:08 mrdezzods

RN 0.46 / RN Swiper 1.5.5

innerexception avatar Aug 09 '17 19:08 innerexception

I just released a new version 1.5.8 . Can you please check with that if the issue is resolved?

mrdezzods avatar Aug 09 '17 19:08 mrdezzods

Unfortunately with RN 0.46 / RN Swiper 1.5.8 all swipers are still blank. Anything else I can check?

innerexception avatar Aug 09 '17 20:08 innerexception

Can you maybe share your code?

mrdezzods avatar Aug 09 '17 20:08 mrdezzods

Sure here's one of my render methods that used to work in 1.5.4:

              return  <View style={{height: '90%'}}>
                                <Swiper onMomentumScrollEnd={(e, state, context) => this.setState({activeView: getActiveViewFromIndex(state.index)})}
                                        loop={true}
                                        index={getIndexFromActiveView(this.state.activeView)}
                                        showsPagination={false}>
                                    <Text>Some content... :)</Text>
                                </Swiper>
                            </View>

innerexception avatar Aug 09 '17 20:08 innerexception

I'm fine, I just reverted to 1.5.4 and all is well. 1.5.8 doesn't seem to work for me though.

innerexception avatar Aug 09 '17 20:08 innerexception

Same here, RN 0.47.1, react-native-swiper 1.5.7 and 1.5.8. Previously worked with RN 0.45.1 and react-native-swiper 1.5.4

This only happens on Android, works fine on iOS

render () {
  return (
    <Modal
      visible={this.state.showModal}
      onRequestClose={this.toggleModal}>
      <View style={styles.closeButton}>
        <IconToggle name='close' color={Colors.snow} onPress={this.toggleModal} />
      </View>
      <View style={styles.centered}>
        <Swiper showsButtons loop={false}>
          <View style={styles.slide1}>
            <Text style={styles.text}>How to Use</Text>
          </View>
          <View style={styles.slide2}>
            <Text style={styles.text}>Why to Use</Text>
          </View>
          <View style={styles.slide3}>
            <Text style={styles.text}>When to Use</Text>
          </View>
        </Swiper>
      </View>
    </Modal>
  )
}

ghost avatar Aug 09 '17 22:08 ghost

when react-native 0.46.4,react-native-swiper 1.5.4 or 1.5.8 not work,What can I do?

liuchengbao avatar Aug 10 '17 08:08 liuchengbao

same.

cbjs avatar Aug 10 '17 08:08 cbjs

@RobertSheaO @jbakerdev Can you fork the project and reproduce the bug with one example? It would be easier for us to help you. @liuchengbao You can do the same and help us make this project works for you

arribbar avatar Aug 10 '17 08:08 arribbar

I was able to narrow it down to the usage of ViewPagerAndroid. I took flex: 1 off and set it to height: 400 and got something to render. Obviously that's not a good fix, but it narrows it down to a styling issue.

ghost avatar Aug 10 '17 08:08 ghost

Maybe you can use height from https://github.com/leecade/react-native-swiper/blob/master/src/index.js#L19. Then, you can erase it with this.props.style. What do you think about this solution ?

arribbar avatar Aug 10 '17 08:08 arribbar

The code in the repo is very different than what's in 1.5.8

Here's the change I made that fixed it.

Old Code

<ViewPagerAndroid ref='scrollView'
  {...this.props}
  initialPage={this.props.loop ? this.state.index + 1 : this.state.index}
  onPageSelected={this.onScrollEnd}
  style={{flex: 1}}>
  {pages}
</ViewPagerAndroid>

New Code

wrapper: {
  backgroundColor: 'transparent',
  height: Dimensions.get('window').height
},

<ViewPagerAndroid ref='scrollView'
  {...this.props}
  initialPage={this.props.loop ? this.state.index + 1 : this.state.index}
  onPageSelected={this.onScrollEnd}
  style={[styles.wrapper, this.props.style]}>
  {pages}
</ViewPagerAndroid>

ghost avatar Aug 10 '17 09:08 ghost

2 questions:

  • Can you try without your changes but the last version, 1.5.9 ?
  • If the bug persists, can you make a PR ?

arribbar avatar Aug 10 '17 09:08 arribbar

1.5.9 isn't pushed to the NPM repository yet, yarn can't find it.

And yes, I'll make a PR if it's not fixed.

ghost avatar Aug 10 '17 09:08 ghost

You can either add directly the git project in your package.json or even easier, make directly the change. You just need to remove one line, cf this commit https://github.com/leecade/react-native-swiper/commit/d1364f5f392a87db432cca1bf51338f7bb1b86e4 Your example seems to work in my case

arribbar avatar Aug 10 '17 09:08 arribbar

@arribbar The weird thing is, what gets pulled down via yarn add [email protected] is very different than what's in github... Here's small sample from the styles object. Notice the lack of wrapperIOS and wrapperAndroid in what gets installed. There's quite a few other differences as well.

react-native-swiper from yarn install

container: {
  backgroundColor: 'transparent',
  position: 'relative'
},

wrapper: {
  backgroundColor: 'transparent'
},

slide: {
  backgroundColor: 'transparent'
},

react-native-swiper from github source

container: {
  backgroundColor: 'transparent',
  position: 'relative',
  flex: 1
},

wrapperIOS: {
  backgroundColor: 'transparent',
},

wrapperAndroid: {
  backgroundColor: 'transparent',
  flex: 1
},

slide: {
  backgroundColor: 'transparent',
},

ghost avatar Aug 10 '17 09:08 ghost

@mrdezzods Maybe there was a bug when you updated npm package. Can you check it ? I can't publish anything on npm. @RobertSheaO Indeed, this is weird. Can you try replacing in package.json react-native-swiper: ... by "react-native-swiper": "git+https://github.com/leecade/react-native-swiper.git" ?

arribbar avatar Aug 10 '17 09:08 arribbar

I don't know why, react natie v0.47 does not display content and blank.

"react-native-swiper": "^1.5.8",

I'm using the basic example

No content, blank, height zero

<Swiper style={styles.wrapper} showsButtons>
    <View style={styles.slide1}>
        <Text style={styles.text}>Hello Swiper</Text>
    </View>
    <View style={styles.slide2}>
        <Text style={styles.text}>Beautiful</Text>
    </View>
    <View style={styles.slide3}>
        <Text style={styles.text}>And simple</Text>
    </View>
</Swiper>

There is content, height is not zero

<View style={styles.slide1}>
    <Text style={styles.text}>Hello Swiper</Text>
</View>
<View style={styles.slide2}>
    <Text style={styles.text}>Beautiful</Text>
</View>
<View style={styles.slide3}>
    <Text style={styles.text}>And simple</Text>
</View>

when I use v1.5.5, there's no problem

Lizhooh avatar Aug 10 '17 09:08 Lizhooh