Skip to content

Instantly share code, notes, and snippets.

@abhimanyuPatil
Created September 27, 2022 14:18
Show Gist options
  • Save abhimanyuPatil/0f34bd7fefb3def7448f7f484576d32e to your computer and use it in GitHub Desktop.
Save abhimanyuPatil/0f34bd7fefb3def7448f7f484576d32e to your computer and use it in GitHub Desktop.
Section with children and props
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>
);
};
@abhimanyuPatil
Copy link
Author

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>

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment