Skip to content

Instantly share code, notes, and snippets.

@JeffGuKang
Created October 6, 2019 12:24
Show Gist options
  • Save JeffGuKang/4df071fb9c422b2aca0a7d52ba675a55 to your computer and use it in GitHub Desktop.
Save JeffGuKang/4df071fb9c422b2aca0a7d52ba675a55 to your computer and use it in GitHub Desktop.
[React Native] PublicText component having same UI for iOS, Android platform
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