React-native-ui-kitten: ViewPager's selectedIndex prop does not change children <View/>

Created on 26 Jul 2019  路  2Comments  路  Source: akveo/react-native-ui-kitten

Issue type

I'm submitting a ... (check one with "x")

  • [x] bug report
  • [ ] feature request

Issue description

Current behavior:
ViewPager's View does not change when selectedIndex props change.
Swiping changes selectedIndex properly.
(Please check the gif below)

Expected behavior:
When change selectedIndex props(with Hooks/setState), ViewPager's View changes

Steps to reproduce:

  1. set ViewPager's selectedIndex prop as state
  2. invoke state change(with Hooks/setState) the selectedIndex prop's state
  3. ViewPager's View does not chage

Related code:

import React, { useState } from 'react';
import { View } from 'react-native';
import { Text, ViewPager, Button } from 'react-native-ui-kitten';

export default function MainPage(){
  const [pageIndex, setIndex] = useState(0);
  const tabNames = ['a', 'b', 'c', 'd', 'e'];
  return(
    <View style={{flex: 1}}>
      <View style={{flex: 0}}>
        <Button onPress={()=>{setIndex(pageIndex - 1)}}> - </Button>
        <Button onPress={()=>{setIndex(pageIndex + 1)}}> + </Button>
      </View>
      <ViewPager style={{flex: 1}}
        selectedIndex={pageIndex}
        onSelect={(number)=>{setIndex(number);}}>
          {tabNames.map((item, index) => (
            <View key={index}>
              <Text>{item}, {index}</Text>
            </View>
          ))}
      </ViewPager>
      <View style={{flex: 0}}>
        <Text>{pageIndex}</Text>
      </View>
    </View>
  )
};

viewpager
Swiping works well, though.
I tried setState instead of hooks, the problem was same.

Other information:

OS, device, package version

Android 9.0
React native 0.60.4
react-native-ui-kitten 4.1.0
Bug Components

All 2 comments

Thanks for reporting this. Will take a look馃憤

@cereme we've got a working example in master branch. Will be published in version 4.2

Was this page helpful?
0 / 5 - 0 ratings

Related issues

Gitldx picture Gitldx  路  3Comments

sovannvin picture sovannvin  路  3Comments

RWOverdijk picture RWOverdijk  路  3Comments

eyalyoli picture eyalyoli  路  3Comments

sobiso picture sobiso  路  3Comments