From 75df5a8ebdc7a8aa3db11f0d3bc3b3f940ca19e8 Mon Sep 17 00:00:00 2001 From: Nam Le Date: Wed, 28 Jun 2023 00:38:54 +0700 Subject: [PATCH 1/6] refactor baseSizeBarScreen to function --- .../SidebarScreen/BaseSidebarScreen.js | 63 ++++++++----------- 1 file changed, 27 insertions(+), 36 deletions(-) diff --git a/src/pages/home/sidebar/SidebarScreen/BaseSidebarScreen.js b/src/pages/home/sidebar/SidebarScreen/BaseSidebarScreen.js index 18622166d4bf..6c56976f9843 100644 --- a/src/pages/home/sidebar/SidebarScreen/BaseSidebarScreen.js +++ b/src/pages/home/sidebar/SidebarScreen/BaseSidebarScreen.js @@ -1,4 +1,4 @@ -import React, {Component} from 'react'; +import React, {useEffect} from 'react'; import {View} from 'react-native'; import styles from '../../../../styles/styles'; import SidebarLinks from '../SidebarLinks'; @@ -17,57 +17,48 @@ const propTypes = { ...windowDimensionsPropTypes, }; -class BaseSidebarScreen extends Component { - constructor(props) { - super(props); - - this.startTimer = this.startTimer.bind(this); - this.navigateToSettings = this.navigateToSettings.bind(this); - } - - componentDidMount() { +function BaseSidebarScreen(props) { + useEffect(() => { Performance.markStart(CONST.TIMING.SIDEBAR_LOADED); Timing.start(CONST.TIMING.SIDEBAR_LOADED, true); - } + }, []); /** * Method called when avatar is clicked */ - navigateToSettings() { + const navigateToSettings = () => { Navigation.navigate(ROUTES.SETTINGS); } /** * Method called when a pinned chat is selected. */ - startTimer() { + const startTimer = () => { Timing.start(CONST.TIMING.SWITCH_REPORT); Performance.markStart(CONST.TIMING.SWITCH_REPORT); } - render() { - return ( - - {({insets}) => ( - <> - - - - {this.props.children} - - )} - - ); - } + return ( + + {({insets}) => ( + <> + + + + {props.children} + + )} + + ); } BaseSidebarScreen.propTypes = propTypes; From 2851d6bc2eb18fe7f9d1a93bbcd50fd46fb6e3ab Mon Sep 17 00:00:00 2001 From: Nam Le Date: Wed, 28 Jun 2023 02:15:40 +0700 Subject: [PATCH 2/6] add displayName for component --- src/pages/home/sidebar/SidebarScreen/BaseSidebarScreen.js | 1 + 1 file changed, 1 insertion(+) diff --git a/src/pages/home/sidebar/SidebarScreen/BaseSidebarScreen.js b/src/pages/home/sidebar/SidebarScreen/BaseSidebarScreen.js index 6c56976f9843..2aa59319be47 100644 --- a/src/pages/home/sidebar/SidebarScreen/BaseSidebarScreen.js +++ b/src/pages/home/sidebar/SidebarScreen/BaseSidebarScreen.js @@ -62,5 +62,6 @@ function BaseSidebarScreen(props) { } BaseSidebarScreen.propTypes = propTypes; +BaseSidebarScreen.displayName = 'BaseSidebarScreen'; export default withWindowDimensions(BaseSidebarScreen); From bb413bec078989f3de00a03e1a4ffb3043867058 Mon Sep 17 00:00:00 2001 From: Nam Le Date: Wed, 28 Jun 2023 18:28:05 +0700 Subject: [PATCH 3/6] move function out of component --- .../SidebarScreen/BaseSidebarScreen.js | 30 +++++++++---------- 1 file changed, 15 insertions(+), 15 deletions(-) diff --git a/src/pages/home/sidebar/SidebarScreen/BaseSidebarScreen.js b/src/pages/home/sidebar/SidebarScreen/BaseSidebarScreen.js index 18cd6a97db28..152be9fca47e 100644 --- a/src/pages/home/sidebar/SidebarScreen/BaseSidebarScreen.js +++ b/src/pages/home/sidebar/SidebarScreen/BaseSidebarScreen.js @@ -17,27 +17,27 @@ const propTypes = { ...windowDimensionsPropTypes, }; +/** +* Method called when avatar is clicked +*/ +const navigateToSettings = () => { + Navigation.navigate(ROUTES.SETTINGS); +} + +/** + * Method called when a pinned chat is selected. + */ +const startTimer = () => { + Timing.start(CONST.TIMING.SWITCH_REPORT); + Performance.markStart(CONST.TIMING.SWITCH_REPORT); +} + function BaseSidebarScreen(props) { useEffect(() => { Performance.markStart(CONST.TIMING.SIDEBAR_LOADED); Timing.start(CONST.TIMING.SIDEBAR_LOADED, true); }, []); - /** - * Method called when avatar is clicked - */ - const navigateToSettings = () => { - Navigation.navigate(ROUTES.SETTINGS); - } - - /** - * Method called when a pinned chat is selected. - */ - const startTimer = () => { - Timing.start(CONST.TIMING.SWITCH_REPORT); - Performance.markStart(CONST.TIMING.SWITCH_REPORT); - } - return ( Date: Wed, 28 Jun 2023 18:38:22 +0700 Subject: [PATCH 4/6] add space in comment function --- src/pages/home/sidebar/SidebarScreen/BaseSidebarScreen.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/pages/home/sidebar/SidebarScreen/BaseSidebarScreen.js b/src/pages/home/sidebar/SidebarScreen/BaseSidebarScreen.js index 152be9fca47e..e2b881b38d37 100644 --- a/src/pages/home/sidebar/SidebarScreen/BaseSidebarScreen.js +++ b/src/pages/home/sidebar/SidebarScreen/BaseSidebarScreen.js @@ -18,8 +18,8 @@ const propTypes = { }; /** -* Method called when avatar is clicked -*/ + * Method called when avatar is clicked + */ const navigateToSettings = () => { Navigation.navigate(ROUTES.SETTINGS); } From e6fde89b67e25db09a1c60cf6eeafefae73d117b Mon Sep 17 00:00:00 2001 From: Nam Le Date: Wed, 28 Jun 2023 22:14:07 +0700 Subject: [PATCH 5/6] fix lint --- src/pages/home/sidebar/SidebarScreen/BaseSidebarScreen.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/pages/home/sidebar/SidebarScreen/BaseSidebarScreen.js b/src/pages/home/sidebar/SidebarScreen/BaseSidebarScreen.js index e2b881b38d37..b954e72f9900 100644 --- a/src/pages/home/sidebar/SidebarScreen/BaseSidebarScreen.js +++ b/src/pages/home/sidebar/SidebarScreen/BaseSidebarScreen.js @@ -22,7 +22,7 @@ const propTypes = { */ const navigateToSettings = () => { Navigation.navigate(ROUTES.SETTINGS); -} +}; /** * Method called when a pinned chat is selected. @@ -30,7 +30,7 @@ const navigateToSettings = () => { const startTimer = () => { Timing.start(CONST.TIMING.SWITCH_REPORT); Performance.markStart(CONST.TIMING.SWITCH_REPORT); -} +}; function BaseSidebarScreen(props) { useEffect(() => { From d7608ba38e5b51321b919a1f6c9453eac95c7f54 Mon Sep 17 00:00:00 2001 From: Nam Le Date: Thu, 29 Jun 2023 17:27:21 +0700 Subject: [PATCH 6/6] fix comment function --- src/pages/home/sidebar/SidebarScreen/BaseSidebarScreen.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/pages/home/sidebar/SidebarScreen/BaseSidebarScreen.js b/src/pages/home/sidebar/SidebarScreen/BaseSidebarScreen.js index b954e72f9900..014170457b3a 100644 --- a/src/pages/home/sidebar/SidebarScreen/BaseSidebarScreen.js +++ b/src/pages/home/sidebar/SidebarScreen/BaseSidebarScreen.js @@ -18,14 +18,14 @@ const propTypes = { }; /** - * Method called when avatar is clicked + * Function called when avatar is clicked */ const navigateToSettings = () => { Navigation.navigate(ROUTES.SETTINGS); }; /** - * Method called when a pinned chat is selected. + * Function called when a pinned chat is selected. */ const startTimer = () => { Timing.start(CONST.TIMING.SWITCH_REPORT);