Created
October 6, 2019 12:24
-
-
Save JeffGuKang/4df071fb9c422b2aca0a7d52ba675a55 to your computer and use it in GitHub Desktop.
[React Native] PublicText component having same UI for iOS, Android platform
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
import React, { ReactNode } from 'react'; | |
import { Text, Platform, TextProps } from 'react-native'; | |
interface Props extends TextProps { | |
children: ReactNode; | |
} | |
const PublicText: React.FC<Props> = ({ style, children, ...props }: Props) => { | |
const defaultStyle = Platform.select({ | |
ios: { fontFamily: 'AppleSDGothicNeo-Regular' }, | |
android: { | |
fontFamily: 'sans-serif', | |
includeFontPadding: false, | |
}, | |
}); | |
return ( | |
<Text {...props} allowFontScaling={false} style={[defaultStyle, style]}> | |
{children} | |
</Text> | |
); | |
}; | |
export { PublicText }; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment