fix: prevent the buttons from flashing when the app starts

pull/3083/head
William Grant 12 months ago
parent e6a26945d5
commit 7349e27dc1

@ -1,5 +1,8 @@
import { useState } from 'react';
import { useDispatch } from 'react-redux'; import { useDispatch } from 'react-redux';
import useMount from 'react-use/lib/useMount'; import useMount from 'react-use/lib/useMount';
import styled from 'styled-components';
import { sleepFor } from '../../../session/utils/Promise';
import { import {
AccountCreation, AccountCreation,
AccountRestoration, AccountRestoration,
@ -15,16 +18,30 @@ import { SpacerLG } from '../../basic/Text';
import { resetRegistration } from '../RegistrationStages'; import { resetRegistration } from '../RegistrationStages';
import { TermsAndConditions } from '../TermsAndConditions'; import { TermsAndConditions } from '../TermsAndConditions';
// NOTE we want to prevent the buttons from flashing when the app starts
const StyledStart = styled.div<{ ready: boolean }>`
${props =>
!props.ready &&
`.session-button {
transition: none;
}`}
`;
export const Start = () => { export const Start = () => {
const [ready, setReady] = useState(false);
const dispatch = useDispatch(); const dispatch = useDispatch();
useMount(() => { useMount(() => {
dispatch(resetOnboardingState()); dispatch(resetOnboardingState());
void resetRegistration(); void resetRegistration();
// eslint-disable-next-line more/no-then
void sleepFor(500).then(() => setReady(true));
}); });
return ( return (
<> <StyledStart ready={ready}>
<SessionButton <SessionButton
buttonColor={SessionButtonColor.White} buttonColor={SessionButtonColor.White}
onClick={() => { onClick={() => {
@ -48,6 +65,6 @@ export const Start = () => {
/> />
<SpacerLG /> <SpacerLG />
<TermsAndConditions /> <TermsAndConditions />
</> </StyledStart>
); );
}; };

Loading…
Cancel
Save