fixt / react-native-page-swiper

91 stars 47 forks source link

Make this a controlled component #5

Open esamattis opened 8 years ago

esamattis commented 8 years ago

I'm keeping my state in Redux store so having extra state inside this component causes weird bugs.

I think this should work like controlled/uncontrolled inputs in standard React: https://facebook.github.io/react/docs/forms.html

Also the prop index is confusing I think it should be renamed to initialIndex and index be used for the controlled behaviour.

cgarvis commented 8 years ago

I don't think this can every be fully stateless do to Animated.View and PanResponder. We should definitely either rename prop or add in componentWillReceiveProp. Do you want to wipe up a concept of a controlled component?

esamattis commented 8 years ago

I will send you a pull request soon for this. And true, you're right it cannot be fully stateless. Animations must have state but the index doesn't which is what actually matters.