complete-guide-to-full-stack-solana-development icon indicating copy to clipboard operation
complete-guide-to-full-stack-solana-development copied to clipboard

Error: Invalid hook call

Open misterch0c opened this issue 3 years ago • 2 comments

Hi,

When trying to run the frontend from any of the examples. I get greeted with the following error:

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.

I googled around and apparently it can happen if different version of react are used. In my case I only see one version, eventhough it's regerenced more than once but it's getting 'deduped':

├─┬ @solana/[email protected]
│ ├─┬ [email protected]
│ │ └── [email protected] deduped
│ └── [email protected]
└─┬ @solana/[email protected]
  └── [email protected] deduped

To reproduce simply npm install in the app folder, then run npm start

misterch0c avatar Nov 16 '21 13:11 misterch0c

Add below dependencies to app/package.json

    "@solana/wallet-adapter-react": "^0.10.3",
    "@solana/wallet-adapter-react-ui": "^0.2.1",
    "@solana/wallet-adapter-wallets": "^0.8.1",

Then npm install npm start

fixes the issue.

build3r avatar Feb 15 '22 10:02 build3r