This code exemplifies the issue:
import { extension } from "@shopify/ui-extensions/customer-account";
return extension(target, (root, api) => {
console.log(api.appMetafields.current) // => Returns undefined while inside the editor, but returns expected value in prod.
setTimeout(() => console.log(api.appMetafields.current), 1000); // => Returns expected value if you wait a bit.
}
It looks like the appMetafields data is loaded asynchronously while inside the editor, but this is not documented. Is that the expected behaviour, or a bug?
We need to access App Metafields in the editor to display the appropriate message(s) to the merchant while they’re setting up the extension.
The different behaviour between editor and prod is surprising and suggests it could be a bug.