Shopify / shopify-app-template-php

263 stars 85 forks source link

ERROR Cannot read properties of null (reading 'useContext') [Fresh Installation] #490

Closed faridmovsumov closed 6 months ago

faridmovsumov commented 6 months ago

Issue summary

I am getting the following error after running yarn dev command in the fresh installation.

ERROR  Cannot read properties of null (reading 'useContext')

 node_modules/@shopify/app/node_modules/react/cjs/react.development.js:1618:21

 1615:     }
 1616:   }
 1617:
 1618:   return dispatcher.useContext(Context);
 1619: }
 1620: function useState(initialState) {
 1621:   var dispatcher = resolveDispatcher();

 - useContext (node_modules/@shopify/app/node_modules/react/cjs/react.development.js:1618:21)
 - useStdin (node_modules/@shopify/app/node_modules/ink/build/hooks/use-stdin.js:6:24)
 - Dev (node_modules/@shopify/app/dist/cli/services/dev/ui/components/Dev.js:13:53)
 -renderWithHoo (node_modules/@shopify/cli-kit/node_modules/react-reconciler/cjs/react-reconc
  s            iler.development.js:7478:18)
 -mountIndeterminateCom (node_modules/@shopify/cli-kit/node_modules/react-reconciler/cjs/reac
  onent                t-reconciler.development.js:11247:13)
 -beginWor (node_modules/@shopify/cli-kit/node_modules/react-reconciler/cjs/react-reconciler.
          development.js:12760:16)
 -beginWork$ (node_modules/@shopify/cli-kit/node_modules/react-reconciler/cjs/react-reconcile
            r.development.js:19569:14)
 -performUnitOfW (node_modules/@shopify/cli-kit/node_modules/react-reconciler/cjs/react-recon
  rk            ciler.development.js:18703:12)
 -workLoopSyn (node_modules/@shopify/cli-kit/node_modules/react-reconciler/cjs/react-reconcil
             er.development.js:18609:5)
 -renderRootSy (node_modules/@shopify/cli-kit/node_modules/react-reconciler/cjs/react-reconci
  c           ler.development.js:18577:7)

image

When running npm run dev command additionally I am getting the following warnings.

Warning: 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.

Expected behavior

React should run.

Actual behavior

Error explained in description thrown.

Steps to reproduce the problem

  1. I just followed the steps in readme.

Checklist

faridmovsumov commented 6 months ago

Running the following command in the root directory solved the problem.

npm update Maybe this information can be added in the readme.