diff --git a/native/chat/compose-thread-button.react.js b/native/chat/compose-thread-button.react.js index db28c9fb0..5cf587a73 100644 --- a/native/chat/compose-thread-button.react.js +++ b/native/chat/compose-thread-button.react.js @@ -1,70 +1,71 @@ // @flow -import PropTypes from 'prop-types'; import * as React from 'react'; import { StyleSheet } from 'react-native'; import Icon from 'react-native-vector-icons/MaterialCommunityIcons'; import { createPendingThread } from 'lib/shared/thread-utils'; import { threadTypes } from 'lib/types/thread-types'; -import { connect } from 'lib/utils/redux-utils'; import Button from '../components/button.react'; import { MessageListRouteName } from '../navigation/route-names'; -import type { AppState } from '../redux/redux-setup'; -import { type Colors, colorsPropType, colorsSelector } from '../themes/colors'; +import { useSelector } from '../redux/redux-utils'; +import { type Colors, useColors } from '../themes/colors'; import type { ChatNavigationProp } from './chat.react'; -type Props = {| +type BaseProps = {| +navigate: $PropertyType, 'navigate'>, - // Redux state +|}; +type Props = {| + ...BaseProps, +colors: Colors, +viewerID: ?string, |}; class ComposeThreadButton extends React.PureComponent { - static propTypes = { - navigate: PropTypes.func.isRequired, - colors: colorsPropType.isRequired, - }; - render() { const { link: linkColor } = this.props.colors; return ( ); } onPress = () => { if (this.props.viewerID) { this.props.navigate({ name: MessageListRouteName, params: { threadInfo: createPendingThread( this.props.viewerID, threadTypes.CHAT_SECRET, [], ), searching: true, }, }); } }; } const styles = StyleSheet.create({ composeButton: { paddingHorizontal: 10, }, }); -export default connect((state: AppState) => ({ - colors: colorsSelector(state), - viewerID: state.currentUserInfo && state.currentUserInfo.id, -}))(ComposeThreadButton); +export default React.memo(function ConnectedComposeThreadButton( + props, +) { + const colors = useColors(); + const viewerID = useSelector( + (state) => state.currentUserInfo && state.currentUserInfo.id, + ); + + return ; +});