diff --git a/native/components/thread-list-thread.react.js b/native/components/thread-list-thread.react.js index dab604df6..d2c32c482 100644 --- a/native/components/thread-list-thread.react.js +++ b/native/components/thread-list-thread.react.js @@ -1,83 +1,70 @@ // @flow -import PropTypes from 'prop-types'; import * as React from 'react'; -import { Text, ViewPropTypes } from 'react-native'; -import { type ThreadInfo, threadInfoPropType } from 'lib/types/thread-types'; -import { connect } from 'lib/utils/redux-utils'; +import { type ThreadInfo } from 'lib/types/thread-types'; -import type { AppState } from '../redux/redux-setup'; -import { - type Colors, - colorsPropType, - colorsSelector, - styleSelector, -} from '../themes/colors'; +import { type Colors, useStyles, useColors } from '../themes/colors'; import type { ViewStyle, TextStyle } from '../types/styles'; import Button from './button.react'; import ColorSplotch from './color-splotch.react'; import { SingleLine } from './single-line.react'; +type BaseProps = {| + +threadInfo: ThreadInfo, + +onSelect: (threadID: string) => void, + +style?: ViewStyle, + +textStyle?: TextStyle, +|}; type Props = {| - threadInfo: ThreadInfo, - onSelect: (threadID: string) => void, - style?: ViewStyle, - textStyle?: TextStyle, - // Redux state - colors: Colors, - styles: typeof styles, + ...BaseProps, + +colors: Colors, + +styles: typeof unboundStyles, |}; class ThreadListThread extends React.PureComponent { - static propTypes = { - threadInfo: threadInfoPropType.isRequired, - onSelect: PropTypes.func.isRequired, - style: ViewPropTypes.style, - textStyle: Text.propTypes.style, - colors: colorsPropType.isRequired, - styles: PropTypes.objectOf(PropTypes.object).isRequired, - }; - render() { const { modalIosHighlightUnderlay: underlayColor } = this.props.colors; return ( ); } onSelect = () => { this.props.onSelect(this.props.threadInfo.id); }; } -const styles = { +const unboundStyles = { button: { alignItems: 'center', flexDirection: 'row', paddingLeft: 13, }, text: { color: 'modalForegroundLabel', fontSize: 16, paddingLeft: 9, paddingRight: 12, paddingVertical: 6, }, }; -const stylesSelector = styleSelector(styles); -export default connect((state: AppState) => ({ - colors: colorsSelector(state), - styles: stylesSelector(state), -}))(ThreadListThread); +export default React.memo(function ConnectedThreadListThread( + props: BaseProps, +) { + const styles = useStyles(unboundStyles); + const colors = useColors(); + + return ; +});