App reviews, troubleshooting, and recommendations
Dear community,
I am getting a hook error using <AppProvider> from @Shopify/discount-app-components library.
You can replicate the error Wrapping part of the App.tsx of your project with the <AppProvider> tag.
import { BrowserRouter } from "react-router-dom";
import { NavigationMenu } from "@shopify/app-bridge-react";
import { AppProvider } from '@shopify/discount-app-components';
import Routes from "./Routes";
import {
AppBridgeProvider,
QueryProvider,
PolarisProvider,
} from "./components";
export default function App() {
// Any .tsx or .jsx files in /pages will become a route
// See documentation for <Routes /> for more info
const pages = import.meta.globEager("./pages/**/!(*.test.[jt]sx)*.([jt]sx)");
return (
<PolarisProvider>
<BrowserRouter>
<AppBridgeProvider>
<AppProvider locale="en-US" ianaTimezone="America/Toronto">
<QueryProvider>
<NavigationMenu
navigationLinks={[
{
label: "Page name",
destination: "/pagename",
},
]}
/>
<Routes pages={pages} />
</QueryProvider>
</AppProvider>
</AppBridgeProvider>
</BrowserRouter>
</PolarisProvider>
);
}
Error:
Uncaught 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 debug and fix this problem.
resolveDispatcher @Shopify_discount-app-components.js:6448
useMemo23 @Shopify_discount-app-components.js:6495
AppProvider @Shopify_discount-app-components.js:39224
renderWithHooks chunk-6YPNWHZK.js:11191
The above error occurred in the <AppProvider> component:
AppProvider@https://f10f-186-4-136-39.sa.ngrok.io/node_modules/.vite/deps/@shopify_discount-app-components.js?v=743b0033:39219:7
DiscountProvider@https://f10f-186-4-136-39.sa.ngrok.io/components/providers/DiscountProvider.jsx:3:33
Provider@https://f10f-186-4-136-39.sa.ngrok.io/node_modules/.vite/deps/@shopify_app-bridge-react.js?v=743b0033:3072:20
AppBridgeProvider@https://f10f-186-4-136-39.sa.ngrok.io/components/providers/AppBridgeProvider.jsx:5:34
Router@https://f10f-186-4-136-39.sa.ngrok.io/node_modules/.vite/deps/react-router-dom.js?v=743b0033:1097:7
BrowserRouter@https://f10f-186-4-136-39.sa.ngrok.io/node_modules/.vite/deps/react-router-dom.js?v=743b0033:1223:7
FocusManager@https://f10f-186-4-136-39.sa.ngrok.io/node_modules/.vite/deps/@shopify_polaris.js?v=743b0033:3568:22
PortalsManager@https://f10f-186-4-136-39.sa.ngrok.io/node_modules/.vite/deps/@shopify_polaris.js?v=743b0033:3544:24
MediaQueryProvider2@https://f10f-186-4-136-39.sa.ngrok.io/node_modules/.vite/deps/@shopify_polaris.js?v=743b0033:3499:54
div
CustomProperties@https://f10f-186-4-136-39.sa.ngrok.io/node_modules/.vite/deps/@shopify_polaris.js?v=743b0033:1285:7
AppProvider@https://f10f-186-4-136-39.sa.ngrok.io/node_modules/.vite/deps/@shopify_polaris.js?v=743b0033:3602:5
PolarisProvider@https://f10f-186-4-136-39.sa.ngrok.io/components/providers/PolarisProvider.jsx:25:32
App
June brought summer energy to our community. Members jumped in with solutions, clicked ...
By JasonH Jun 5, 2025Learn how to build powerful custom workflows in Shopify Flow with expert guidance from ...
By Jacqui May 7, 2025Did You Know? May is named after Maia, the Roman goddess of growth and flourishing! ...
By JasonH May 2, 2025