Created
July 30, 2019 10:46
-
-
Save gHashTag/fe0c4783143b2003c09e87e8bd2810a5 to your computer and use it in GitHub Desktop.
CurrentIndex - React Hook
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const App = () => { | |
const { container } = styles | |
const [currentIndex, setCurrentIndex] = useState(0) | |
const array = [{ title: "Today" }, { title: "Week" }, { title: "Month" }] | |
return ( | |
<View style={container}> | |
<Text>{${currentIndex}}</Text> | |
{array.map(({ title }, i) => ( | |
<TouchableOpacity key={title} onPress={() => setCurrentIndex(i)}> | |
<Text>{title}</Text> | |
</TouchableOpacity> | |
))} | |
</View> | |
) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment