Giter Club home page Giter Club logo

Comments (11)

olivierlesnicki avatar olivierlesnicki commented on July 20, 2024

This can already be done using the scrollTo(index) method.

from react-native-swiper.

rreusser avatar rreusser commented on July 20, 2024

Can you clarify how one might use this? Does this require two-way binding? I.e. swiping modifies an index state variable, and modifying a state variable switches to a given slide? That would require extending this component with that behavior, right?

from react-native-swiper.

nautical avatar nautical commented on July 20, 2024

The way I am doing it in my project is assigning ref to it , you can do something like :

      <Swiper style={styles.wrapper} ref={component => this._swiperobj = component} > ... </Swiper>

Then you can call this._swiperobj.scrollTo(1);
or something like that based on your condition .

from react-native-swiper.

rreusser avatar rreusser commented on July 20, 2024

Oh wow, I didn't know that was a thing you could do. I was doing it with two-way binding, e.g.:

<Swiper
  index={this.state.swiperIndex}
  onIndexChange={(idx) => this.setState({swiperIndex: idx})}
> 

which of course requires implementing onIndexChange within Swiper, but I'm already digging through guts to solve a couple other corner cases…

from react-native-swiper.

rreusser avatar rreusser commented on July 20, 2024

And also requires picking up index prop changes within Swiper. The ref method seems kind of like a hack, but it's pretty compelling when you just need to get the job done.

from react-native-swiper.

nautical avatar nautical commented on July 20, 2024

Yes , ref is a powerful tool , and by the way , why do you feel it looks like a hack ? It doesn't cost on performance or usability .

from react-native-swiper.

rreusser avatar rreusser commented on July 20, 2024

At any rate, I think I'll finish implementing the two-way method since it's more react-ish and should probably exist anyway. Commits will probably end up on this fork (if I can get the infinite loop case working): https://github.com/manandmoon/react-native-swiper

from react-native-swiper.

rreusser avatar rreusser commented on July 20, 2024

@nautical revisiting this with some hindsight (and because it's now painfully unmaintained and doesn't work anymore). Yeah, you're totally right. That's way easier and perfectly reactish. Noob mistake. But looks like now we'll have to swap this out for react-native-viewpager.

from react-native-swiper.

olivierlesnicki avatar olivierlesnicki commented on July 20, 2024

@leecade is alive!!!

from react-native-swiper.

leecade avatar leecade commented on July 20, 2024

@olivierlesnicki yeah I work on RN again

from react-native-swiper.

joaoeffting avatar joaoeffting commented on July 20, 2024

@nautical MY HERO <3

from react-native-swiper.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.