Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Android only]: Tab's width doesn't get adjusted on updating the values dynamically #720

Open
pranshuchittora opened this issue May 4, 2023 · 1 comment · May be fixed by #721
Open

Comments

@pranshuchittora
Copy link

When values are updated on runtime the tab width doesn't get updated. This happens only in Android, currently, the tab width is recomputed only on layout changes.

Screen.Recording.2023-05-04.at.11.42.05.PM.720.mov

Here's the code sample for the above example

import {View, Button, SafeAreaView} from 'react-native';
import React, {useState} from 'react';
import SegmentedControl from '@react-native-segmented-control/segmented-control';

export default function App() {
  const getTabs = (prevTabs: string[] = []) => {
    return [...prevTabs, (prevTabs.length + 1).toString()];
  };

  const [tabs, setTabs] = useState<string[]>(getTabs());
  const [selectedTabIndex, setSelectedTabIndex] = useState<number>(0);

  return (
    <SafeAreaView>
      <View>
        <SegmentedControl
          values={tabs}
          selectedIndex={selectedTabIndex}
          onChange={event => {
            setSelectedTabIndex(event.nativeEvent.selectedSegmentIndex);
          }}
        />
        <Button title="Add Tabs" onPress={() => setTabs(getTabs(tabs))} />
      </View>
    </SafeAreaView>
  );
}

Deps

    "@react-native-segmented-control/segmented-control": "^2.4.1",
    "react": "18.2.0",
    "react-native": "0.71.7"
@Tavernari
Copy link

Same here! ☝️

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants