Skip to content

Instantly share code, notes, and snippets.

@ChronSyn
Created May 7, 2020 15:43
Show Gist options
  • Save ChronSyn/35df57eec90bc3f2e070dda0cae86730 to your computer and use it in GitHub Desktop.
Save ChronSyn/35df57eec90bc3f2e070dda0cae86730 to your computer and use it in GitHub Desktop.
CustomText component which can display expo google fonts. Direct replacement for Text from react-native
import * as React from "react";
import { Text, TextProps } from "react-native";
import { useFonts } from '@use-expo/font';
import {
Nunito_Regular400,
Nunito_SemiBold600_Italic,
} from '@expo-google-fonts/nunito';
const CustomText: React.FC<TextProps> = (props) => {
const [fontsLoaded] = useFonts({
Nunito_Regular400,
Nunito_SemiBold600_Italic,
});
return fontsLoaded
? <Text style={[props.style, { fontFamily: "Nunito_Regular400" }]}>{props.children}</Text>
: <></>
}
export default CustomText;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment