import { hot } from 'react-hot-loader/root';
import React from 'react';
import { ProtonApp, useAuthentication, useInstance } from 'react-components';
import createSecureSessionStorage from 'proton-shared/lib/createSecureSessionStorage';
import { MAILBOX_PASSWORD_KEY, UID_KEY } from 'proton-shared/lib/constants';
import sentry from 'proton-shared/lib/helpers/sentry';

import * as config from './config';
import PrivateApp from './PrivateApp';
import PublicApp from './PublicApp';

import './app.scss';

sentry(config);

const Setup = () => {
    const { UID, login, logout } = useAuthentication();
    if (UID) {
        return <PrivateApp onLogout={logout} />;
    }
    return <PublicApp onLogin={login} />;
};

const App = () => {
    const storage = useInstance(() => createSecureSessionStorage([MAILBOX_PASSWORD_KEY, UID_KEY]));
    return (
        <ProtonApp config={config} storage={storage}>
            <Setup />
        </ProtonApp>
    );
};

export default hot(App);

@@ -106,21 +106,8 @@
 tion
-, useInstance
  %7D f
@@ -134,172 +134,8 @@
 s';%0A
-import createSecureSessionStorage from 'proton-shared/lib/createSecureSessionStorage';%0Aimport %7B MAILBOX_PASSWORD_KEY, UID_KEY %7D from 'proton-shared/lib/constants';%0A
 impo
@@ -556,108 +556,8 @@
 %3E %7B%0A
-    const storage = useInstance(() =%3E createSecureSessionStorage(%5BMAILBOX_PASSWORD_KEY, UID_KEY%5D));%0A
     
@@ -603,26 +603,8 @@
 fig%7D
- storage=%7Bstorage%7D
 %3E%0A  

Move back session storage creation