From 57ed851db64e3584cbe8ab4c2b518d1a2bc23f42 Mon Sep 17 00:00:00 2001 From: Gleidson Daniel Date: Mon, 8 Aug 2022 10:11:11 -0300 Subject: [PATCH 1/3] migrate WithoutServerView to hooks --- app/views/WithoutServersView.tsx | 48 +++++++++++++++----------------- 1 file changed, 23 insertions(+), 25 deletions(-) diff --git a/app/views/WithoutServersView.tsx b/app/views/WithoutServersView.tsx index 91cfe1319f3..011f8c2aa4a 100644 --- a/app/views/WithoutServersView.tsx +++ b/app/views/WithoutServersView.tsx @@ -1,12 +1,12 @@ -import React from 'react'; +import React, { useEffect } 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 { setOptions } = useNavigation(); + const { colors } = useTheme(); -class WithoutServerView extends React.Component { - static navigationOptions = () => ({ - title: 'Rocket.Chat', - headerLeft: () => - }); + useEffect(() => { + setOptions({ + title: 'Rocket.Chat', + headerLeft: () => + }); + }, []); - 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; From 719cc32494cf93d4e0b954d327f87009848b1e3d Mon Sep 17 00:00:00 2001 From: Gleidson Daniel Date: Mon, 8 Aug 2022 14:59:10 -0300 Subject: [PATCH 2/3] remove navigation options --- app/share.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/share.tsx b/app/share.tsx index 08918148384..01476f14034 100644 --- a/app/share.tsx +++ b/app/share.tsx @@ -73,7 +73,7 @@ const OutsideStack = () => { return ( - + ); }; From 75a56253d38aee4e243c405ccc618b87b795ed6b Mon Sep 17 00:00:00 2001 From: Reinaldo Neto Date: Tue, 9 Aug 2022 17:12:36 -0300 Subject: [PATCH 3/3] minor tweak --- app/views/WithoutServersView.tsx | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/app/views/WithoutServersView.tsx b/app/views/WithoutServersView.tsx index 011f8c2aa4a..362229765a0 100644 --- a/app/views/WithoutServersView.tsx +++ b/app/views/WithoutServersView.tsx @@ -1,4 +1,4 @@ -import React, { useEffect } 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'; @@ -27,15 +27,15 @@ const styles = StyleSheet.create({ }); const WithoutServerView = (): React.ReactElement => { - const { setOptions } = useNavigation(); + const navigation = useNavigation(); const { colors } = useTheme(); - useEffect(() => { - setOptions({ + useLayoutEffect(() => { + navigation.setOptions({ title: 'Rocket.Chat', headerLeft: () => }); - }, []); + }, [navigation]); return (