Created
September 27, 2022 14:18
-
-
Save abhimanyuPatil/0f34bd7fefb3def7448f7f484576d32e to your computer and use it in GitHub Desktop.
Section with children and props
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 Section: React.FC< | |
PropsWithChildren<{ | |
title: string; | |
}> | |
> = ({ children, title }) => { | |
const isDarkMode = useColorScheme() === "dark"; | |
return ( | |
<View style={styles.sectionContainer}> | |
<Text | |
style={[ | |
styles.sectionTitle, | |
{ | |
color: isDarkMode ? Colors.white : Colors.black, | |
}, | |
]} | |
> | |
{title} | |
</Text> | |
<Text | |
style={[ | |
styles.sectionDescription, | |
{ | |
color: isDarkMode ? Colors.light : Colors.dark, | |
}, | |
]} | |
> | |
{children} | |
</Text> | |
</View> | |
); | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Usage
<Section title="Step One"> Edit <Text style={styles.highlight}>App.tsx</Text> to change this screen and then come back to see your edits. </Section>