[add] forwardedRef prop to View and Text

Ref #1172
This commit is contained in:
Nicolas Gallagher
2019-10-04 11:35:53 -07:00
parent d57fb6eb01
commit 33f1c3566c
4 changed files with 6 additions and 0 deletions
@@ -29,6 +29,7 @@ const TextPropTypes = {
accessible: bool,
accessibilityState: object,
children: any,
forwardedRef: any,
importantForAccessibility: oneOf(['auto', 'no', 'no-hide-descendants', 'yes']),
maxFontSizeMultiplier: number,
nativeID: string,
+2
View File
@@ -26,6 +26,7 @@ class Text extends React.Component<*> {
renderText(hasTextAncestor) {
const {
dir,
forwardedRef,
numberOfLines,
onPress,
selectable,
@@ -67,6 +68,7 @@ class Text extends React.Component<*> {
];
// allow browsers to automatically infer the language writing direction
otherProps.dir = dir !== undefined ? dir : 'auto';
otherProps.ref = forwardedRef;
otherProps.style = [
style,
numberOfLines > 1 && { WebkitLineClamp: numberOfLines },
@@ -60,6 +60,7 @@ export type ViewProps = {
accessible?: boolean,
children?: any,
className?: string,
forwardedRef?: any,
hitSlop?: EdgeInsetsProp,
importantForAccessibility?: 'auto' | 'yes' | 'no' | 'no-hide-descendants',
nativeID?: string,
@@ -117,6 +118,7 @@ const ViewPropTypes = {
accessibilityState: object,
accessible: bool,
children: any,
forwardedRef: any,
hitSlop: EdgeInsetsPropType,
importantForAccessibility: oneOf(['auto', 'no', 'no-hide-descendants', 'yes']),
nativeID: string,
+1
View File
@@ -52,6 +52,7 @@ class View extends Component<ViewProps> {
}
supportedProps.classList = [this.props.className, classes.view];
supportedProps.ref = this.props.forwardedRef;
supportedProps.style = StyleSheet.compose(
hasTextAncestor && styles.inline,
this.props.style