Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 12 additions & 2 deletions src/pages/signin/SignInPageLayout/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import compose from '../../../libs/compose';
import SignInPageContent from './SignInPageContent';
import Footer from './Footer';
import withWindowDimensions, {windowDimensionsPropTypes} from '../../../components/withWindowDimensions';
import withLocalize, {withLocalizePropTypes} from '../../../components/withLocalize';
import styles from '../../../styles/styles';
import SignInPageHero from '../SignInPageHero';
import * as StyleUtils from '../../../styles/StyleUtils';
Expand All @@ -15,6 +16,7 @@ import SignInHeroBackgroundImage from '../../../../assets/images/home-background
import SignInHeroBackgroundImageMobile from '../../../../assets/images/home-background--mobile.svg';
import SignInGradient from '../../../../assets/images/home-fade-gradient.svg';
import variables from '../../../styles/variables';
import usePrevious from '../../../hooks/usePrevious';

const propTypes = {
/** The children to show inside the layout */
Expand All @@ -35,10 +37,12 @@ const propTypes = {
shouldShowWelcomeHeader: PropTypes.bool.isRequired,

...windowDimensionsPropTypes,
...withLocalizePropTypes,
};

function SignInPageLayout(props) {
const scrollViewRef = useRef();
const prevPreferredLocale = usePrevious(props.preferredLocale);
let containerStyles = [styles.flex1, styles.signInPageInner];
let contentContainerStyles = [styles.flex1, styles.flexRow];

Expand All @@ -57,7 +61,13 @@ function SignInPageLayout(props) {
scrollViewRef.current.scrollTo({y: 0, animated});
};

useEffect(scrollPageToTop, [props.welcomeHeader, props.welcomeText]);
useEffect(() => {

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's add a comment here explaining what's going on with this hook.

@hoangzinh hoangzinh Jun 28, 2023

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do you agree with?

# If the welcomeHeader or welcomeText are changed by changing preferredLocale, we should not scroll page to top

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

let's drop the comment. Its fine.

if (prevPreferredLocale !== props.preferredLocale) {
return;
}

scrollPageToTop();
}, [props.welcomeHeader, props.welcomeText, prevPreferredLocale, props.preferredLocale]);

return (
<View style={containerStyles}>
Expand Down Expand Up @@ -138,4 +148,4 @@ function SignInPageLayout(props) {
SignInPageLayout.propTypes = propTypes;
SignInPageLayout.displayName = 'SignInPageLayout';

export default compose(withWindowDimensions, withSafeAreaInsets)(SignInPageLayout);
export default compose(withWindowDimensions, withSafeAreaInsets, withLocalize)(SignInPageLayout);