mattermost-mobile/app/components/post_list/with_layout.js
Elias Nahum 82dc62dfc6
Fix Posts cutoff (#2071)
* Remove PixelRatio from emoji

* Fix removeSubclippedViews in emoji picker

* Add system emojis to the store handler

* Pass element to whyDidYouUpdate util

* Fix post avoidable re-renders

* Fix emoji on Android

* Feedback review
2018-09-04 11:53:15 -03:00

41 lines
1.2 KiB
JavaScript

// Copyright (c) 2015-present Mattermost, Inc. All Rights Reserved.
// See LICENSE.txt for license information.
import React, {PureComponent} from 'react';
import PropTypes from 'prop-types';
import {View} from 'react-native';
import {emptyFunction} from 'app/utils/general';
function withLayout(WrappedComponent) {
return class WithLayoutComponent extends PureComponent {
static propTypes = {
index: PropTypes.number.isRequired,
onLayoutCalled: PropTypes.func,
shouldCallOnLayout: PropTypes.bool,
};
static defaultProps = {
onLayoutCalled: emptyFunction,
};
onLayout = (event) => {
const {height} = event.nativeEvent.layout;
const {shouldCallOnLayout} = this.props;
if (shouldCallOnLayout) {
this.props.onLayoutCalled(this.props.index, height);
}
};
render() {
const {index, onLayoutCalled, shouldCallOnLayout, ...otherProps} = this.props; //eslint-disable-line no-unused-vars
return (
<View onLayout={this.onLayout}>
<WrappedComponent {...otherProps}/>
</View>
);
}
};
}
export default withLayout;