From a101d319e572562d09819a28163be536efe5be28 Mon Sep 17 00:00:00 2001 From: Gleidson Daniel Silva Date: Thu, 11 Aug 2022 11:41:18 -0300 Subject: [PATCH] Chore: Migrate WithoutServerView to hooks (#4415) * migrate WithoutServerView to hooks * remove navigation options * minor tweak Co-authored-by: Reinaldo Neto <47038980+reinaldonetof@users.noreply.github.com> Co-authored-by: Reinaldo Neto --- app/share.tsx | 2 +- app/views/WithoutServersView.tsx | 48 +++++++++++++++----------------- 2 files changed, 24 insertions(+), 26 deletions(-) diff --git a/app/share.tsx b/app/share.tsx index f347c5ae5..7c6933912 100644 --- a/app/share.tsx +++ b/app/share.tsx @@ -72,7 +72,7 @@ const OutsideStack = () => { return ( - + ); }; diff --git a/app/views/WithoutServersView.tsx b/app/views/WithoutServersView.tsx index 91cfe1319..362229765 100644 --- a/app/views/WithoutServersView.tsx +++ b/app/views/WithoutServersView.tsx @@ -1,12 +1,12 @@ -import React from 'react'; +import React, { useLayoutEffect } from 'react'; import { StyleSheet, Text, View } from 'react-native'; import ShareExtension from 'rn-extensions-share'; +import { useNavigation } from '@react-navigation/native'; import * as HeaderButton from '../containers/HeaderButton'; -import sharedStyles from './Styles'; import I18n from '../i18n'; -import { themes } from '../lib/constants'; -import { TSupportedThemes, withTheme } from '../theme'; +import { useTheme } from '../theme'; +import sharedStyles from './Styles'; const styles = StyleSheet.create({ container: { @@ -26,27 +26,25 @@ const styles = StyleSheet.create({ } }); -interface IWithoutServerViewProps { - theme: TSupportedThemes; -} +const WithoutServerView = (): React.ReactElement => { + const navigation = useNavigation(); + const { colors } = useTheme(); -class WithoutServerView extends React.Component { - static navigationOptions = () => ({ - title: 'Rocket.Chat', - headerLeft: () => - }); + useLayoutEffect(() => { + navigation.setOptions({ + title: 'Rocket.Chat', + headerLeft: () => + }); + }, [navigation]); - render() { - const { theme } = this.props; - return ( - - {I18n.t('Without_Servers')} - - {I18n.t('You_need_to_access_at_least_one_RocketChat_server_to_share_something')} - - - ); - } -} + return ( + + {I18n.t('Without_Servers')} + + {I18n.t('You_need_to_access_at_least_one_RocketChat_server_to_share_something')} + + + ); +}; -export default withTheme(WithoutServerView); +export default WithoutServerView;