B – Selected Index
First, our component needs the most basic functionality: We should at least be able to select a segment by tapping it. Let’s make this thing interactive.The index state Tap handler function Displaying the selected segmentThe index stateI added an index state variable (and a setIndex() function to change it) with an initial value of 0:export default function […]