mirror of
https://github.com/zoriya/react-native-web.git
synced 2026-06-02 02:25:22 +00:00
Docs: allow AppText to inherit font-size
This commit is contained in:
@@ -4,16 +4,27 @@
|
|||||||
* @flow
|
* @flow
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
import { bool } from 'prop-types';
|
||||||
import React from 'react';
|
import React from 'react';
|
||||||
import { StyleSheet, Text } from 'react-native';
|
import { StyleSheet, Text } from 'react-native';
|
||||||
|
|
||||||
const AppText = ({ style, ...rest }) => (
|
class AppText extends React.PureComponent {
|
||||||
<Text
|
static contextTypes = {
|
||||||
{...rest}
|
isInAParentText: bool
|
||||||
accessibilityRole={rest.href ? 'link' : undefined}
|
};
|
||||||
style={[styles.baseText, style, rest.href && styles.link]}
|
|
||||||
/>
|
render() {
|
||||||
);
|
const { style, ...rest } = this.props;
|
||||||
|
const isInAParentText = this.context;
|
||||||
|
return (
|
||||||
|
<Text
|
||||||
|
{...rest}
|
||||||
|
accessibilityRole={rest.href ? 'link' : undefined}
|
||||||
|
style={[!isInAParentText && styles.baseText, style, rest.href && styles.link]}
|
||||||
|
/>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
export default AppText;
|
export default AppText;
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user