react-native-ios-utilities
Version:
Utilities for react-native + iOS
35 lines • 1 kB
JavaScript
import * as React from 'react';
import { View } from 'react-native';
export class WrapperView extends React.PureComponent {
nativeRef;
reactTag;
componentWillUnmount() {
this.reactTag = undefined;
}
;
getViewRef = () => {
return this.nativeRef;
};
getNativeReactTag = () => {
// @ts-ignore
return this.nativeRef?.nativeTag ?? this.reactTag;
};
_handleViewRef = (ref) => {
this.nativeRef = ref;
};
_handleOnLayout = (event) => {
this.props.onLayout?.(event);
// @ts-ignore
this.reactTag = event.nativeEvent.target;
};
render() {
const { children, ...otherProps } = this.props;
const didSetReactTag = this.reactTag != null;
return (React.createElement(View, { ...otherProps, ref: this._handleViewRef, onLayout: didSetReactTag
? undefined
: this._handleOnLayout }, children));
}
;
}
;
//# sourceMappingURL=WrapperView.js.map