Skip to content

Commit 33f1c35

Browse files
committed
[add] forwardedRef prop to View and Text
Ref #1172
1 parent d57fb6e commit 33f1c35

File tree

4 files changed

+6
-0
lines changed

4 files changed

+6
-0
lines changed

packages/react-native-web/src/exports/Text/TextPropTypes.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ const TextPropTypes = {
2929
accessible: bool,
3030
accessibilityState: object,
3131
children: any,
32+
forwardedRef: any,
3233
importantForAccessibility: oneOf(['auto', 'no', 'no-hide-descendants', 'yes']),
3334
maxFontSizeMultiplier: number,
3435
nativeID: string,

packages/react-native-web/src/exports/Text/index.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ class Text extends React.Component<*> {
2626
renderText(hasTextAncestor) {
2727
const {
2828
dir,
29+
forwardedRef,
2930
numberOfLines,
3031
onPress,
3132
selectable,
@@ -67,6 +68,7 @@ class Text extends React.Component<*> {
6768
];
6869
// allow browsers to automatically infer the language writing direction
6970
otherProps.dir = dir !== undefined ? dir : 'auto';
71+
otherProps.ref = forwardedRef;
7072
otherProps.style = [
7173
style,
7274
numberOfLines > 1 && { WebkitLineClamp: numberOfLines },

packages/react-native-web/src/exports/View/ViewPropTypes.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,7 @@ export type ViewProps = {
6060
accessible?: boolean,
6161
children?: any,
6262
className?: string,
63+
forwardedRef?: any,
6364
hitSlop?: EdgeInsetsProp,
6465
importantForAccessibility?: 'auto' | 'yes' | 'no' | 'no-hide-descendants',
6566
nativeID?: string,
@@ -117,6 +118,7 @@ const ViewPropTypes = {
117118
accessibilityState: object,
118119
accessible: bool,
119120
children: any,
121+
forwardedRef: any,
120122
hitSlop: EdgeInsetsPropType,
121123
importantForAccessibility: oneOf(['auto', 'no', 'no-hide-descendants', 'yes']),
122124
nativeID: string,

packages/react-native-web/src/exports/View/index.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,7 @@ class View extends Component<ViewProps> {
5252
}
5353

5454
supportedProps.classList = [this.props.className, classes.view];
55+
supportedProps.ref = this.props.forwardedRef;
5556
supportedProps.style = StyleSheet.compose(
5657
hasTextAncestor && styles.inline,
5758
this.props.style

0 commit comments

Comments
 (0)