<ScrollableSegmentedControl offsetScrollbars={false} segmentFgColor={colors.blue1}…
- User
<ScrollableSegmentedControl offsetScrollbars={false} segmentFgColor={colors.blue1} segmentData={challengeTabs.tabs[ selectedChallenge ].runnerUpTeams .slice(0, 2) .map((tab, index) => ({ label: index <= 1 ?
Runner Up ${index + 1}:Team ${index + 1}, value: index.toString(), }))} onChange={(value) => { setSelectedRunnerUp(Number(value)); }} value={selectedRunnerUp.toString()} /> modify this for me cuz we no longer need the if condition as we will only have runner up 1 and runner up 2 - Assistant
You can simplify the
labelgeneration for thesegmentDataby removing the condition that checks the index since you will always only have "Runner Up 1" and "Runner Up 2". Here's the modified code snippet:<ScrollableSegmentedControl offsetScrollbars={false} segmentFgColor={colors.blue1} segmentData={challengeTabs.tabs[selectedChallenge].runnerUpTeams .slice(0, 2) .map((tab, index) => ({ label: `Runner Up ${index + 1}`, // Directly use the index to generate the label value: index.toString(), }))} onChange={(value) => { setSelectedRunnerUp(Number(value)); }} value={selectedRunnerUp.toString()} />This code now generates the labels for both tabs directly as "Runner Up 1" and "Runner Up 2" based on their indices without any conditional checks.