MetaMask / metamask-sdk

The simplest yet most secure way to connect your blockchain-based applications to millions of MetaMask Wallet users.
https://metamask.io/sdk/
Other
188 stars 115 forks source link

[Bug]: sdk and other properties are undefined when using `useSDK()` #995

Open ozgurrgul opened 2 months ago

ozgurrgul commented 2 months ago

SDK

React-Native

Provide environment information

 "@metamask/sdk-react-native": "^0.3.6",
 "node-libs-react-native": "^1.2.1",
 "react-native": "0.72.13",
 "react-native-get-random-values": "^1.11.0",
"react-native-url-polyfill": "^2.0.0",
"eciesjs": "^0.4.7",
 "ethers": "5.7.2",

MetaMask REACTREACT SDK Version

0.3.6

MetaMask Mobile app Version

v7.28.1(1386)

What browser are you using? (if relevant)

No response

How are you deploying your application? (if relevant)

No response

Describe the Bug

Hello, following the basic tutorial for to implement Metamask SDK into our React native app: https://docs.metamask.io/wallet/how-to/use-sdk/javascript/react-native/

When I simply log the outcome of the hook, everything is undefined.

import { useSDK } from '@metamask/sdk-react-native';

// consume hook
const { sdk, connected } = useSDK();
console.log({sdk})

output:

{"sdk": undefined}

Expected Behavior

It should not be undefined so that we can call sdk?.connect(() method

Link to reproduction - Issues with a link to complete (but minimal) reproduction code will be addressed faster

No response

To Reproduce

Simply follow the tutorial. Also note that your tutorial has incorrect usage and needs to be updated since connect() method and others moved into the sdk https://docs.metamask.io/wallet/how-to/use-sdk/javascript/react-native/#7-use-the-sdk