diff --git a/native/components/user-list.react.js b/native/components/user-list.react.js index 5a5b06a8e..ceb4b1af2 100644 --- a/native/components/user-list.react.js +++ b/native/components/user-list.react.js @@ -1,79 +1,71 @@ // @flow -import { type UserListItem, userListItemPropType } from 'lib/types/user-types'; -import { connect } from 'lib/utils/redux-utils'; +import type { UserListItem } from 'lib/types/user-types'; import _sum from 'lodash/fp/sum'; -import PropTypes from 'prop-types'; import React from 'react'; -import { FlatList, Text } from 'react-native'; +import { FlatList } from 'react-native'; -import type { AppState } from '../redux/redux-setup'; -import { - type IndicatorStyle, - indicatorStylePropType, - indicatorStyleSelector, -} from '../themes/colors'; +import { type IndicatorStyle, useIndicatorStyle } from '../themes/colors'; import type { TextStyle } from '../types/styles'; import { UserListUser, getUserListItemHeight } from './user-list-user.react'; +type BaseProps = {| + +userInfos: $ReadOnlyArray, + +onSelect: (userID: string) => void, + +itemTextStyle?: TextStyle, +|}; type Props = { - userInfos: $ReadOnlyArray, - onSelect: (userID: string) => void, - itemTextStyle?: TextStyle, + ...BaseProps, // Redux state - indicatorStyle: IndicatorStyle, + +indicatorStyle: IndicatorStyle, }; class UserList extends React.PureComponent { - static propTypes = { - userInfos: PropTypes.arrayOf(userListItemPropType).isRequired, - onSelect: PropTypes.func.isRequired, - itemTextStyle: Text.propTypes.style, - indicatorStyle: indicatorStylePropType.isRequired, - }; - render() { return ( ); } static keyExtractor(userInfo: UserListItem) { return userInfo.id; } renderItem = (row: { item: UserListItem }) => { return ( ); }; static getItemLayout(data: ?$ReadOnlyArray, index: number) { if (!data) { return { length: 0, offset: 0, index }; } const offset = _sum( data.filter((_, i) => i < index).map(getUserListItemHeight), ); const item = data[index]; const length = item ? getUserListItemHeight(item) : 0; return { length, offset, index }; } } -export default connect((state: AppState) => ({ - indicatorStyle: indicatorStyleSelector(state), -}))(UserList); +export default React.memo(function ConnectedUserList( + props: BaseProps, +) { + const indicatorStyle = useIndicatorStyle(); + return ; +});