Accessing context in Custom UI in App.js

I have created a custom UI app for ProjectPage. In the App.js as a testing step I want to render the accountId of the current user. But the view.getContext() returns not the accountId or any other property of the context. Is this not how it supposed to work in App.js?

import React, { useEffect, useState } from 'react';
import { invoke, view } from '@forge/bridge';

function App() {
    const context = view.getContext();
    
    return (
        <div>
            Hello, {context.accountId}!
        </div>
    );
}

export default App;

Probably related to this: [FRGE-753] - Ecosystem Jira

I assumed the same thing would work when I added a license check to a Forge app.

It’s an undocumented bug as usual. You need to fetch the data server-side using invoke.

Oh dear, solution is pretty easy. getContext is async, so it needs to be added an await and then placed outside of function App.

import React, { useEffect, useState } from 'react';
import { invoke, view } from '@forge/bridge';

const context = await view.getContext();

function App() {
    
    return (
        <div>
            <p>
                Hello {context.accountId} at {context.siteUrl}
            </p>
        </div>
    );
}

export default App;