import React, { useState, useLayoutEffect } from 'react';
import PropTypes from 'prop-types';
import { Route, Switch } from 'react-router-dom';
import { Loader, LoginForm, ModalsChildren } from 'react-components';
import { loadOpenPGP } from 'proton-shared/lib/openpgp';

const PublicApp = ({ onLogin }) => {
    const [loading, setLoading] = useState(true);
    const [error, setError] = useState(false);

    useLayoutEffect(() => {
        (async () => {
            await Promise.all([loadOpenPGP()]);
        })()
            .then(() => setLoading(false))
            .catch(() => setError(true));
    }, []);

    if (error) {
        return 'OpenPGP failed to load. Handle better.';
    }

    if (loading) {
        return (
            <>
                <Loader />
            </>
        );
    }

    return (
        <>
            <ModalsChildren />
            <Switch>
                <Route render={() => <LoginForm onLogin={onLogin} />} />
            </Switch>
        </>
    );
};

PublicApp.propTypes = {
    onLogin: PropTypes.func.isRequired
};

export default PublicApp;

@@ -9,39 +9,8 @@
 eact
-, %7B useState, useLayoutEffect %7D
  fro
@@ -115,22 +115,33 @@
 mport %7B 
-Loader
+StandardPublicApp
 , LoginF
@@ -191,626 +191,85 @@
 s';%0A
-import %7B loadOpenPGP %7D from 'proton-shared/lib/openpgp';%0A%0Aconst PublicApp = (%7B onLogin %7D) =%3E %7B%0A    const %5Bloading, setLoading%5D = useState(true);%0A    const %5Berror, setError%5D = useState(false);%0A%0A    useLayoutEffect(() =%3E %7B%0A        (async () =%3E %7B%0A            await Promise.all(%5BloadOpenPGP()%5D);%0A        %7D)()%0A            .then(() =%3E setLoading(false))%0A            .catch(() =%3E setError(true));%0A    %7D, %5B%5D);%0A%0A    if (error) %7B%0A        return 'OpenPGP failed to load. Handle better.';%0A    %7D%0A%0A    if (loading) %7B%0A        return (%0A            %3C%3E%0A                %3CLoader /%3E%0A            %3C/%3E%0A        );%0A    %7D%0A%0A    return (%0A        %3C
+%0Aconst PublicApp = (%7B onLogin %7D) =%3E %7B%0A    return (%0A        %3CStandardPublicApp
 %3E%0A  
@@ -423,16 +423,33 @@
       %3C/
+StandardPublicApp
 %3E%0A    );

Use standard public app