Skip to content

Instantly share code, notes, and snippets.

@thibaut-d
Created September 16, 2020 13:40
Show Gist options
  • Save thibaut-d/c44af2bc11afe6723817b0fa69c1756b to your computer and use it in GitHub Desktop.
Save thibaut-d/c44af2bc11afe6723817b0fa69c1756b to your computer and use it in GitHub Desktop.
Basic functional component for React Native with TypeScript
import React, { FC } from 'react'
import { StyleSheet, Text, View } from 'react-native'
interface Props {
/** prop1 documentation */
prop1: string
}
/**
* Component description
*
* @param props - {@link Props}
*/
const ComponentName: FC<Props> = ({ prop1 }: Props) => {
return (
<View style={styles.container}>
<Text style={styles.inContainer}>Work in progress {prop1}</Text>
</View>
)
}
const styles = StyleSheet.create({
container: {
flex: 1, // full space
flexDirection: 'row', // elements disposition
justifyContent: 'center', // following flexDirection
alignItems: 'center', // perpendicular to flexDirection
},
inContainer: {
alignSelf: 'center', // following flex direction
},
})
export default ComponentName
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment