Shopify Public App Node Template with Subscription Extension Error

chirag_viradiya
Shopify Partner
19 2 4

I've created a Hello World Shopify Public app with node template and trying to create Shopify Extension for the Subscription.

But Having issue to use the 

@Shopify/admin-ui-extensions-react's hooks which is listed below:
useData / 
useContainer /
useSessionToken /
useLocale
 
It's coming with error once I'm trying use any of the hooks in my function

Sample Code:
import { Text, extend, render, useData, useContainer, useSessionToken, useLocale } from '@shopify/admin-ui-extensions-react';
function Create() { const data = useData(); return ( <Text> We do not support creating products directly to plans at this moment. -- {data?.productId} </Text> ); }
extend( 'Admin::Product::SubscriptionPlan::Create', render(() => <Create />), )
Error:
chirag_viradiya_0-1717780427810.png


Error Message at line which I've useData written:
Error: Invalid hook call. Hooks can only be called inside of the body of a function component. This could happen for one of the following reasons:
1. You might have mismatching versions of React and the renderer (such as React DOM)
2. You might be breaking the Rules of Hooks
3. You might have more than one copy of React in the same app
See https://reactjs.org/link/invalid-hook-call for tips about how to


Is anyone having same issue?


NOTE: I'm using node template with reactjs


 
  • Linked-in
  • Github
  • Whatsapp
  • Twitter
Replies 0 (0)