Description
Please list the package(s) involved in the issue, and include the version you are using
@shopify/ui-extensions version 2024.10.1
@shopify/ui-extensions-react version 2024.10.1
Describe the bug
When using the admin.product-index.action.render target with the useApi hook in TypeScript, the returned object does not include the expected data key that should be present according to the BlockExtensionApi return signature. The returned object only contains navigation, intents, auth, close, storage, extension, i18n, and query properties.
Steps to reproduce the behavior:
Setup:
Create an extension using the admin.product-index.action.render target
Implement the useApi hook in TypeScript
Steps:
Set up the following code:
import {
AdminAction,
BlockStack,
Button,
reactExtension,
Text,
useApi,
} from "@shopify/ui-extensions-react/admin";
import { useEffect, useState } from "react";
const TARGET = "admin.product-index.action.render";
export default reactExtension(TARGET, () => <App />);
function App() {
const targetValues = useApi(TARGET);
const { i18n, data, close } = targetValues;
console.log("Data", close, data, targetValues);
return (
<AdminAction
primaryAction={
<Button
onPress={() => {
console.log("saving");
close();
}}
>
Done
</Button>
}
secondaryAction={
<Button
onPress={() => {
console.log("closing");
close();
}}
>
Close
</Button>
}
>
<BlockStack>
<Text>
All data: {JSON.stringify(targetValues)},{" "}
{JSON.stringify(Object.keys(targetValues))}
</Text>
</BlockStack>
</AdminAction>
);
}
The main part:
const TARGET = "admin.product-index.action.render";
const targetValues = useApi(TARGET);
console.log(Object.keys(targetValues))
App has proper permissions in shopify.app.toml:
[access_scopes]
scopes = "read_products,write_products"
Observe the console output showing only:
["navigation","intents","auth","close","storage","extension","i18n","query"]
Note that the data property containing product selection data is missing.
Expected behavior
The useApi hook should return an object that includes the data key containing product selection data, as specified in the BlockExtensionApi return signature and consistent with other selection endpoints.