From 1a52c7dc576108db1dc1cb9c88d1fc25913b3346 Mon Sep 17 00:00:00 2001 From: Reinaldo Neto <47038980+reinaldonetof@users.noreply.github.com> Date: Tue, 17 May 2022 10:39:21 -0300 Subject: [PATCH] Chore: Evaluate AddChannelTeamView - TypeScript (#4170) --- app/views/AddChannelTeamView.tsx | 33 +++++++++++++++----------------- 1 file changed, 15 insertions(+), 18 deletions(-) diff --git a/app/views/AddChannelTeamView.tsx b/app/views/AddChannelTeamView.tsx index 2675feb1d..7b924b59e 100644 --- a/app/views/AddChannelTeamView.tsx +++ b/app/views/AddChannelTeamView.tsx @@ -1,7 +1,7 @@ import React, { useEffect } from 'react'; import { StackNavigationOptions, StackNavigationProp } from '@react-navigation/stack'; -import { RouteProp } from '@react-navigation/native'; -import { connect } from 'react-redux'; +import { RouteProp, useNavigation, useRoute } from '@react-navigation/native'; +import { useSelector } from 'react-redux'; import { CompositeNavigationProp } from '@react-navigation/core'; import * as List from '../containers/List'; @@ -10,15 +10,14 @@ import * as HeaderButton from '../containers/HeaderButton'; import SafeAreaView from '../containers/SafeAreaView'; import I18n from '../i18n'; import { ChatsStackParamList, DrawerParamList, NewMessageStackParamList } from '../stacks/types'; +import { IApplicationState } from '../definitions'; -interface IAddChannelTeamView { - navigation: CompositeNavigationProp< - StackNavigationProp, - CompositeNavigationProp, StackNavigationProp> - >; - route: RouteProp; - isMasterDetail: boolean; -} +type TRoute = RouteProp; + +type TNavigation = CompositeNavigationProp< + StackNavigationProp, + CompositeNavigationProp, StackNavigationProp> +>; const setHeader = ({ navigation, @@ -38,12 +37,14 @@ const setHeader = ({ navigation.setOptions(options); }; -const AddChannelTeamView = ({ navigation, route, isMasterDetail }: IAddChannelTeamView) => { - const { teamId, teamChannels } = route.params; +const AddChannelTeamView = () => { + const navigation = useNavigation(); + const isMasterDetail = useSelector((state: IApplicationState) => state.app.isMasterDetail); + const { teamChannels, teamId } = useRoute().params; useEffect(() => { setHeader({ navigation, isMasterDetail }); - }, []); + }, [isMasterDetail, navigation]); return ( @@ -80,8 +81,4 @@ const AddChannelTeamView = ({ navigation, route, isMasterDetail }: IAddChannelTe ); }; -const mapStateToProps = (state: any) => ({ - isMasterDetail: state.app.isMasterDetail -}); - -export default connect(mapStateToProps)(AddChannelTeamView); +export default AddChannelTeamView;